-
Notifications
You must be signed in to change notification settings - Fork 0
/
convin.cpp
37 lines (37 loc) · 1.05 KB
/
convin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cstdio>
#include <iostream>
using namespace std;
int portb[202];
int porth[202];
int hubp[200005];
int b[200005],p[200005],l[200005],c[200005];
int main()
{
int m;
scanf("%d",&m);
for (int i=1;i<=m;i++)
{
scanf("%*s%d%d%d%d",&b[i],&p[i],&l[i],&c[i]);
portb[b[i]]=max(portb[b[i]],p[i]+1);
hubp[i]=porth[l[i]]++;
}
for (int i=1;i<=200;i++)
if (portb[i])
printf("let b%d = new Bridge(%d, \'b%d\', new MAC(%d))\n",i,portb[i],i,i);
for (int i=1;i<=200;i++)
if (porth[i])
printf("let h%d = new Hub(%d, \'h%d\')\n",i,porth[i],i);
puts("graph.data(graph.save())");
puts("graph.render()");
for (int i=1;i<=m;i++)
{
printf("connect(b%d.ports[%d], h%d.ports[%d], %d)\n",b[i],p[i],l[i],hubp[i],c[i]);
}
puts("function convout() {");
for (int i=1;i<=m;i++)
{
printf("console.log(`%d %d %d ${[, 'BP', 'RP', 'DP'][b%d.ports[%d].role]}`)\n",b[i],p[i],l[i],b[i],p[i]);
}
puts("}");
puts("setTimeout(convout, 40*MS_PER_SECOND)");
}