# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
283867 | 2020-08-26T08:31:03 Z | hank55663 | Simurgh (IOI17_simurgh) | C++14 | 308 ms | 2296 KB |
#include "simurgh.h" #define x first #define y second #define pb push_back #include<bits/stdc++.h> using namespace std; int f[505]; int Find(int x){ if(f[x]==x)return x; return f[x]=Find(f[x]); } int check[250500]; int ok[250500]; std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { vector<int> ans; int m=u.size(); for(int i = 0;i<n;i++){ for(int j=0;j<n;j++)f[j]=j; vector<int> road; vector<int> road2; vector<int> candidate; for(int j = 0;j<m;j++){ if(u[j]!=i&&v[j]!=i){ if(Find(u[j])!=Find(v[j])){ road.pb(j); f[Find(u[j])]=Find(v[j]); } } else{ candidate.pb(j); //printf("%d %d\n",i,j); } } map<int,vector<int> > m; for(auto it:candidate){ if(u[it]==i){ m[Find(v[it])].pb(it); } else{ m[Find(u[it])].pb(it); } } vector<pair<int,vector<int> > > v; for(auto it:m){ v.pb(it); road2.pb(it.y[0]); } for(auto it:road){ road2.pb(it); } swap(road,road2); for(int i = 0;i<v.size();i++){ int x=-1; for(auto it:v[i].y){ if(check[it]){ x=it; break; } } if(x!=-1) road[i]=x; } int x=count_common_roads(road); // printf("!\n"); for(int j = 0;j<v.size();j++){ int need=x; int now=road[j]; vector<int> res; if(check[now]&&!ok[now])need++; for(auto it:v[j].y){ if(!check[it]){ road[j]=it; int y=count_common_roads(road); // printf("! %d\n",it); if(y>need){ res.clear(); need=y; } if(y==need){ res.push_back(it); } } } for(auto it:res)check[it]=1,ok[it]=1,ans.pb(it);//printf("%d\n",it); for(auto it:v[j].y){ if(!check[it]){ check[it]=1; ok[it]=0; } } road[j]=now; // printf("%d end\n",i); } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | correct |
2 | Correct | 1 ms | 256 KB | correct |
3 | Correct | 1 ms | 384 KB | correct |
4 | Correct | 1 ms | 384 KB | correct |
5 | Correct | 0 ms | 256 KB | correct |
6 | Correct | 1 ms | 256 KB | correct |
7 | Correct | 1 ms | 256 KB | correct |
8 | Correct | 1 ms | 256 KB | correct |
9 | Correct | 0 ms | 256 KB | correct |
10 | Correct | 1 ms | 256 KB | correct |
11 | Correct | 1 ms | 384 KB | correct |
12 | Correct | 1 ms | 384 KB | correct |
13 | Correct | 1 ms | 256 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | correct |
2 | Correct | 1 ms | 256 KB | correct |
3 | Correct | 1 ms | 384 KB | correct |
4 | Correct | 1 ms | 384 KB | correct |
5 | Correct | 0 ms | 256 KB | correct |
6 | Correct | 1 ms | 256 KB | correct |
7 | Correct | 1 ms | 256 KB | correct |
8 | Correct | 1 ms | 256 KB | correct |
9 | Correct | 0 ms | 256 KB | correct |
10 | Correct | 1 ms | 256 KB | correct |
11 | Correct | 1 ms | 384 KB | correct |
12 | Correct | 1 ms | 384 KB | correct |
13 | Correct | 1 ms | 256 KB | correct |
14 | Correct | 3 ms | 384 KB | correct |
15 | Correct | 3 ms | 384 KB | correct |
16 | Correct | 3 ms | 384 KB | correct |
17 | Correct | 4 ms | 384 KB | correct |
18 | Correct | 2 ms | 384 KB | correct |
19 | Correct | 4 ms | 384 KB | correct |
20 | Correct | 4 ms | 384 KB | correct |
21 | Correct | 3 ms | 384 KB | correct |
22 | Correct | 2 ms | 384 KB | correct |
23 | Correct | 3 ms | 384 KB | correct |
24 | Correct | 3 ms | 384 KB | correct |
25 | Correct | 1 ms | 384 KB | correct |
26 | Correct | 2 ms | 384 KB | correct |
27 | Correct | 2 ms | 384 KB | correct |
28 | Correct | 2 ms | 384 KB | correct |
29 | Correct | 1 ms | 384 KB | correct |
30 | Correct | 2 ms | 384 KB | correct |
31 | Correct | 2 ms | 384 KB | correct |
32 | Correct | 2 ms | 384 KB | correct |
33 | Correct | 2 ms | 384 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | correct |
2 | Correct | 1 ms | 256 KB | correct |
3 | Correct | 1 ms | 384 KB | correct |
4 | Correct | 1 ms | 384 KB | correct |
5 | Correct | 0 ms | 256 KB | correct |
6 | Correct | 1 ms | 256 KB | correct |
7 | Correct | 1 ms | 256 KB | correct |
8 | Correct | 1 ms | 256 KB | correct |
9 | Correct | 0 ms | 256 KB | correct |
10 | Correct | 1 ms | 256 KB | correct |
11 | Correct | 1 ms | 384 KB | correct |
12 | Correct | 1 ms | 384 KB | correct |
13 | Correct | 1 ms | 256 KB | correct |
14 | Correct | 3 ms | 384 KB | correct |
15 | Correct | 3 ms | 384 KB | correct |
16 | Correct | 3 ms | 384 KB | correct |
17 | Correct | 4 ms | 384 KB | correct |
18 | Correct | 2 ms | 384 KB | correct |
19 | Correct | 4 ms | 384 KB | correct |
20 | Correct | 4 ms | 384 KB | correct |
21 | Correct | 3 ms | 384 KB | correct |
22 | Correct | 2 ms | 384 KB | correct |
23 | Correct | 3 ms | 384 KB | correct |
24 | Correct | 3 ms | 384 KB | correct |
25 | Correct | 1 ms | 384 KB | correct |
26 | Correct | 2 ms | 384 KB | correct |
27 | Correct | 2 ms | 384 KB | correct |
28 | Correct | 2 ms | 384 KB | correct |
29 | Correct | 1 ms | 384 KB | correct |
30 | Correct | 2 ms | 384 KB | correct |
31 | Correct | 2 ms | 384 KB | correct |
32 | Correct | 2 ms | 384 KB | correct |
33 | Correct | 2 ms | 384 KB | correct |
34 | Correct | 308 ms | 1056 KB | correct |
35 | Correct | 290 ms | 1224 KB | correct |
36 | Correct | 198 ms | 964 KB | correct |
37 | Correct | 21 ms | 384 KB | correct |
38 | Correct | 279 ms | 1272 KB | correct |
39 | Correct | 266 ms | 1120 KB | correct |
40 | Correct | 193 ms | 896 KB | correct |
41 | Correct | 286 ms | 1152 KB | correct |
42 | Correct | 295 ms | 1152 KB | correct |
43 | Correct | 150 ms | 768 KB | correct |
44 | Correct | 124 ms | 640 KB | correct |
45 | Correct | 148 ms | 820 KB | correct |
46 | Correct | 108 ms | 640 KB | correct |
47 | Correct | 49 ms | 512 KB | correct |
48 | Correct | 8 ms | 384 KB | correct |
49 | Correct | 20 ms | 384 KB | correct |
50 | Correct | 50 ms | 632 KB | correct |
51 | Correct | 148 ms | 888 KB | correct |
52 | Correct | 123 ms | 760 KB | correct |
53 | Correct | 114 ms | 700 KB | correct |
54 | Correct | 150 ms | 888 KB | correct |
55 | Correct | 143 ms | 888 KB | correct |
56 | Correct | 154 ms | 820 KB | correct |
57 | Correct | 148 ms | 768 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | correct |
2 | Correct | 1 ms | 256 KB | correct |
3 | Incorrect | 188 ms | 2296 KB | WA in grader: NO |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | correct |
2 | Correct | 1 ms | 256 KB | correct |
3 | Correct | 1 ms | 384 KB | correct |
4 | Correct | 1 ms | 384 KB | correct |
5 | Correct | 0 ms | 256 KB | correct |
6 | Correct | 1 ms | 256 KB | correct |
7 | Correct | 1 ms | 256 KB | correct |
8 | Correct | 1 ms | 256 KB | correct |
9 | Correct | 0 ms | 256 KB | correct |
10 | Correct | 1 ms | 256 KB | correct |
11 | Correct | 1 ms | 384 KB | correct |
12 | Correct | 1 ms | 384 KB | correct |
13 | Correct | 1 ms | 256 KB | correct |
14 | Correct | 3 ms | 384 KB | correct |
15 | Correct | 3 ms | 384 KB | correct |
16 | Correct | 3 ms | 384 KB | correct |
17 | Correct | 4 ms | 384 KB | correct |
18 | Correct | 2 ms | 384 KB | correct |
19 | Correct | 4 ms | 384 KB | correct |
20 | Correct | 4 ms | 384 KB | correct |
21 | Correct | 3 ms | 384 KB | correct |
22 | Correct | 2 ms | 384 KB | correct |
23 | Correct | 3 ms | 384 KB | correct |
24 | Correct | 3 ms | 384 KB | correct |
25 | Correct | 1 ms | 384 KB | correct |
26 | Correct | 2 ms | 384 KB | correct |
27 | Correct | 2 ms | 384 KB | correct |
28 | Correct | 2 ms | 384 KB | correct |
29 | Correct | 1 ms | 384 KB | correct |
30 | Correct | 2 ms | 384 KB | correct |
31 | Correct | 2 ms | 384 KB | correct |
32 | Correct | 2 ms | 384 KB | correct |
33 | Correct | 2 ms | 384 KB | correct |
34 | Correct | 308 ms | 1056 KB | correct |
35 | Correct | 290 ms | 1224 KB | correct |
36 | Correct | 198 ms | 964 KB | correct |
37 | Correct | 21 ms | 384 KB | correct |
38 | Correct | 279 ms | 1272 KB | correct |
39 | Correct | 266 ms | 1120 KB | correct |
40 | Correct | 193 ms | 896 KB | correct |
41 | Correct | 286 ms | 1152 KB | correct |
42 | Correct | 295 ms | 1152 KB | correct |
43 | Correct | 150 ms | 768 KB | correct |
44 | Correct | 124 ms | 640 KB | correct |
45 | Correct | 148 ms | 820 KB | correct |
46 | Correct | 108 ms | 640 KB | correct |
47 | Correct | 49 ms | 512 KB | correct |
48 | Correct | 8 ms | 384 KB | correct |
49 | Correct | 20 ms | 384 KB | correct |
50 | Correct | 50 ms | 632 KB | correct |
51 | Correct | 148 ms | 888 KB | correct |
52 | Correct | 123 ms | 760 KB | correct |
53 | Correct | 114 ms | 700 KB | correct |
54 | Correct | 150 ms | 888 KB | correct |
55 | Correct | 143 ms | 888 KB | correct |
56 | Correct | 154 ms | 820 KB | correct |
57 | Correct | 148 ms | 768 KB | correct |
58 | Correct | 0 ms | 256 KB | correct |
59 | Correct | 1 ms | 256 KB | correct |
60 | Incorrect | 188 ms | 2296 KB | WA in grader: NO |
61 | Halted | 0 ms | 0 KB | - |