#include "meetings.h"
#include "bits/stdc++.h"
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
using namespace std;
int root;
vector<int>path;
bool cmp(int x,int y){
return (Query(root,x,y)==x);
}
void print(int x,int y){
if(x>y)swap(x,y);
Bridge(x,y);
}
void f(vector<int>v){
int sz=int(v.size());
if(sz<2)
return;
if(sz==2){
print(v[0],v[1]);
return;
}
path.clear();
random_shuffle(v.begin(),v.end());
int a=1,b=0;
a=v[a];b=v[b];root=a;
map<int,vector<int> >pm;
tr(it,v)
if(*it!=a && *it!=b){
int c=Query(a,b,*it);
if(!pm.count(c) && c!=a && c!=b)
path.push_back(c);
pm[c].push_back(*it);
}
pm[a].push_back(a);pm[b].push_back(b);
if(path.empty())
print(a,b);
else{
sort(path.begin(),path.end(),cmp);
print(a,path[0]);
for(int i=0;i<int(path.size())-1;i++)
print(path[i],path[i+1]);
print(path.back(),b);
}
tr(it,pm)f(it->second);
}
void Solve(int N){
srand((unsigned)time(NULL));
vector<int>v;
for(int i=0;i<N;i++)
v.push_back(i);
f(v);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Correct |
1 ms |
364 KB |
Output is correct |
25 |
Correct |
1 ms |
364 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
8 ms |
364 KB |
Output is correct |
29 |
Correct |
6 ms |
364 KB |
Output is correct |
30 |
Correct |
6 ms |
364 KB |
Output is correct |
31 |
Correct |
5 ms |
364 KB |
Output is correct |
32 |
Correct |
7 ms |
364 KB |
Output is correct |
33 |
Correct |
9 ms |
364 KB |
Output is correct |
34 |
Correct |
11 ms |
364 KB |
Output is correct |
35 |
Correct |
10 ms |
364 KB |
Output is correct |
36 |
Correct |
4 ms |
364 KB |
Output is correct |
37 |
Correct |
9 ms |
492 KB |
Output is correct |
38 |
Correct |
15 ms |
492 KB |
Output is correct |
39 |
Correct |
10 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
411 ms |
748 KB |
Output is correct |
2 |
Correct |
573 ms |
880 KB |
Output is correct |
3 |
Correct |
405 ms |
748 KB |
Output is correct |
4 |
Correct |
464 ms |
620 KB |
Output is correct |
5 |
Correct |
351 ms |
620 KB |
Output is correct |
6 |
Correct |
429 ms |
748 KB |
Output is correct |
7 |
Correct |
469 ms |
876 KB |
Output is correct |
8 |
Correct |
554 ms |
876 KB |
Output is correct |
9 |
Correct |
580 ms |
896 KB |
Output is correct |
10 |
Correct |
464 ms |
780 KB |
Output is correct |
11 |
Correct |
641 ms |
748 KB |
Output is correct |
12 |
Correct |
406 ms |
748 KB |
Output is correct |
13 |
Correct |
221 ms |
804 KB |
Output is correct |
14 |
Correct |
424 ms |
748 KB |
Output is correct |
15 |
Correct |
285 ms |
1004 KB |
Output is correct |
16 |
Correct |
476 ms |
748 KB |
Output is correct |
17 |
Correct |
532 ms |
876 KB |
Output is correct |
18 |
Correct |
324 ms |
748 KB |
Output is correct |
19 |
Correct |
357 ms |
876 KB |
Output is correct |
20 |
Correct |
447 ms |
748 KB |
Output is correct |
21 |
Correct |
357 ms |
748 KB |
Output is correct |
22 |
Correct |
411 ms |
748 KB |
Output is correct |
23 |
Correct |
471 ms |
876 KB |
Output is correct |
24 |
Correct |
374 ms |
792 KB |
Output is correct |
25 |
Correct |
406 ms |
748 KB |
Output is correct |
26 |
Correct |
315 ms |
748 KB |
Output is correct |
27 |
Correct |
339 ms |
620 KB |
Output is correct |
28 |
Correct |
564 ms |
748 KB |
Output is correct |
29 |
Correct |
454 ms |
748 KB |
Output is correct |
30 |
Correct |
551 ms |
748 KB |
Output is correct |
31 |
Correct |
529 ms |
748 KB |
Output is correct |
32 |
Correct |
906 ms |
924 KB |
Output is correct |
33 |
Correct |
611 ms |
1004 KB |
Output is correct |
34 |
Correct |
6 ms |
364 KB |
Output is correct |
35 |
Correct |
6 ms |
364 KB |
Output is correct |
36 |
Correct |
5 ms |
364 KB |
Output is correct |
37 |
Correct |
5 ms |
364 KB |
Output is correct |
38 |
Correct |
5 ms |
364 KB |
Output is correct |
39 |
Correct |
7 ms |
364 KB |
Output is correct |
40 |
Correct |
9 ms |
364 KB |
Output is correct |
41 |
Correct |
14 ms |
492 KB |
Output is correct |
42 |
Correct |
12 ms |
364 KB |
Output is correct |
43 |
Correct |
6 ms |
364 KB |
Output is correct |
44 |
Correct |
10 ms |
492 KB |
Output is correct |
45 |
Correct |
11 ms |
492 KB |
Output is correct |
46 |
Correct |
11 ms |
492 KB |
Output is correct |
47 |
Correct |
1 ms |
364 KB |
Output is correct |
48 |
Correct |
1 ms |
364 KB |
Output is correct |
49 |
Correct |
1 ms |
364 KB |
Output is correct |
50 |
Correct |
1 ms |
364 KB |
Output is correct |
51 |
Correct |
1 ms |
364 KB |
Output is correct |
52 |
Correct |
1 ms |
364 KB |
Output is correct |
53 |
Correct |
1 ms |
364 KB |
Output is correct |
54 |
Correct |
1 ms |
364 KB |
Output is correct |
55 |
Correct |
1 ms |
364 KB |
Output is correct |
56 |
Correct |
1 ms |
364 KB |
Output is correct |
57 |
Correct |
1 ms |
364 KB |
Output is correct |
58 |
Correct |
1 ms |
364 KB |
Output is correct |
59 |
Correct |
1 ms |
364 KB |
Output is correct |
60 |
Correct |
0 ms |
364 KB |
Output is correct |
61 |
Correct |
1 ms |
364 KB |
Output is correct |
62 |
Correct |
0 ms |
364 KB |
Output is correct |
63 |
Correct |
0 ms |
364 KB |
Output is correct |
64 |
Correct |
0 ms |
364 KB |
Output is correct |
65 |
Correct |
0 ms |
364 KB |
Output is correct |
66 |
Correct |
0 ms |
364 KB |
Output is correct |
67 |
Correct |
0 ms |
364 KB |
Output is correct |
68 |
Correct |
0 ms |
364 KB |
Output is correct |
69 |
Correct |
1 ms |
364 KB |
Output is correct |
70 |
Correct |
0 ms |
364 KB |
Output is correct |
71 |
Correct |
0 ms |
364 KB |
Output is correct |
72 |
Correct |
1 ms |
364 KB |
Output is correct |