# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73391 | 2018-08-28T08:12:45 Z | mr_banana | Simurgh (IOI17_simurgh) | C++17 | 349 ms | 6152 KB |
#include <bits/stdc++.h> #include "simurgh.h" using namespace std; const int MN=1e5+100; vector<int> adj[MN]; int from[MN],to[MN]; int par[MN],h[MN]; bool mark[MN]; set<int> e; int n,m; int vaz[MN]; void dfs(int v){ mark[v]=1; for(int e1:adj[v]){ int u=from[e1]^to[e1]^v; if(!mark[u]){ par[u]=e1; e.insert(e1); h[u]=h[v]+1; dfs(u); } } } int get(){ vector<int> ask; for(int i:e){ ask.push_back(i); } return count_common_roads(ask); } vector<int> find_roads(int N, vector<int> u, vector<int> v) { n=N,m=u.size(); for(int i=0;i<m;i++){ from[i]=u[i]; to[i]=v[i]; adj[u[i]].push_back(i); adj[v[i]].push_back(i); } dfs(0); memset(vaz,-1,sizeof vaz); int base=get(); for(int i=0;i<m;i++){ if(e.count(i)==0){ vector<int> path; vector<int> pans; int u1=from[i],v1=to[i]; if(h[u1]<h[v1]){ swap(u1,v1); } for(int i=h[u1]-h[v1];i>0;i--){ path.push_back(par[u1]); u1=from[par[u1]]^to[par[u1]]^u1; } while(u1!=v1){ path.push_back(par[u1]); u1=from[par[u1]]^to[par[u1]]^u1; path.push_back(par[v1]); v1=from[par[v1]]^to[par[v1]]^v1; } for(int j=0;j<path.size();j++){ if((vaz[path[j]]!=-1 && vaz[i]==-1)){ e.erase(path[j]); e.insert(i); int x=get(); e.insert(path[j]); e.erase(i); if(x<base){ vaz[i]=0; } else if(x>base){ vaz[i]=1; } else{ vaz[i]=vaz[path[j]]; } pans.push_back(0); } else if(vaz[path[j]]==-1){ e.erase(path[j]); e.insert(i); int x=get(); e.insert(path[j]); e.erase(i); if(x<base){ vaz[i]=0; vaz[path[j]]=1; pans.push_back(0); } else if(x>base){ vaz[i]=1; vaz[path[j]]=0; pans.push_back(0); } else{ pans.push_back(1); } } else{ pans.push_back(0); } } if(vaz[i]==-1){ vaz[i]=0; } for(int j=0;j<path.size();j++){ if(pans[j]==1){ vaz[path[j]]=vaz[i]; } } } } vector<int> ans; for(int i=0;i<m;i++){ if(vaz[i]!=0){ ans.push_back(i); } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3064 KB | correct |
2 | Correct | 6 ms | 3176 KB | correct |
3 | Correct | 7 ms | 3240 KB | correct |
4 | Correct | 8 ms | 3240 KB | correct |
5 | Correct | 6 ms | 3360 KB | correct |
6 | Correct | 7 ms | 3360 KB | correct |
7 | Correct | 7 ms | 3360 KB | correct |
8 | Correct | 6 ms | 3360 KB | correct |
9 | Correct | 7 ms | 3360 KB | correct |
10 | Correct | 7 ms | 3360 KB | correct |
11 | Correct | 7 ms | 3360 KB | correct |
12 | Correct | 6 ms | 3360 KB | correct |
13 | Correct | 6 ms | 3360 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3064 KB | correct |
2 | Correct | 6 ms | 3176 KB | correct |
3 | Correct | 7 ms | 3240 KB | correct |
4 | Correct | 8 ms | 3240 KB | correct |
5 | Correct | 6 ms | 3360 KB | correct |
6 | Correct | 7 ms | 3360 KB | correct |
7 | Correct | 7 ms | 3360 KB | correct |
8 | Correct | 6 ms | 3360 KB | correct |
9 | Correct | 7 ms | 3360 KB | correct |
10 | Correct | 7 ms | 3360 KB | correct |
11 | Correct | 7 ms | 3360 KB | correct |
12 | Correct | 6 ms | 3360 KB | correct |
13 | Correct | 6 ms | 3360 KB | correct |
14 | Correct | 12 ms | 3360 KB | correct |
15 | Correct | 11 ms | 3360 KB | correct |
16 | Correct | 13 ms | 3360 KB | correct |
17 | Correct | 10 ms | 3360 KB | correct |
18 | Correct | 8 ms | 3360 KB | correct |
19 | Correct | 10 ms | 3360 KB | correct |
20 | Correct | 9 ms | 3360 KB | correct |
21 | Correct | 10 ms | 3360 KB | correct |
22 | Correct | 8 ms | 3360 KB | correct |
23 | Correct | 9 ms | 3360 KB | correct |
24 | Correct | 9 ms | 3360 KB | correct |
25 | Correct | 10 ms | 3360 KB | correct |
26 | Correct | 9 ms | 3360 KB | correct |
27 | Correct | 9 ms | 3360 KB | correct |
28 | Correct | 8 ms | 3360 KB | correct |
29 | Correct | 7 ms | 3360 KB | correct |
30 | Correct | 8 ms | 3368 KB | correct |
31 | Correct | 9 ms | 3368 KB | correct |
32 | Correct | 10 ms | 3368 KB | correct |
33 | Correct | 11 ms | 3368 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3064 KB | correct |
2 | Correct | 6 ms | 3176 KB | correct |
3 | Correct | 7 ms | 3240 KB | correct |
4 | Correct | 8 ms | 3240 KB | correct |
5 | Correct | 6 ms | 3360 KB | correct |
6 | Correct | 7 ms | 3360 KB | correct |
7 | Correct | 7 ms | 3360 KB | correct |
8 | Correct | 6 ms | 3360 KB | correct |
9 | Correct | 7 ms | 3360 KB | correct |
10 | Correct | 7 ms | 3360 KB | correct |
11 | Correct | 7 ms | 3360 KB | correct |
12 | Correct | 6 ms | 3360 KB | correct |
13 | Correct | 6 ms | 3360 KB | correct |
14 | Correct | 12 ms | 3360 KB | correct |
15 | Correct | 11 ms | 3360 KB | correct |
16 | Correct | 13 ms | 3360 KB | correct |
17 | Correct | 10 ms | 3360 KB | correct |
18 | Correct | 8 ms | 3360 KB | correct |
19 | Correct | 10 ms | 3360 KB | correct |
20 | Correct | 9 ms | 3360 KB | correct |
21 | Correct | 10 ms | 3360 KB | correct |
22 | Correct | 8 ms | 3360 KB | correct |
23 | Correct | 9 ms | 3360 KB | correct |
24 | Correct | 9 ms | 3360 KB | correct |
25 | Correct | 10 ms | 3360 KB | correct |
26 | Correct | 9 ms | 3360 KB | correct |
27 | Correct | 9 ms | 3360 KB | correct |
28 | Correct | 8 ms | 3360 KB | correct |
29 | Correct | 7 ms | 3360 KB | correct |
30 | Correct | 8 ms | 3368 KB | correct |
31 | Correct | 9 ms | 3368 KB | correct |
32 | Correct | 10 ms | 3368 KB | correct |
33 | Correct | 11 ms | 3368 KB | correct |
34 | Correct | 349 ms | 4332 KB | correct |
35 | Correct | 313 ms | 4332 KB | correct |
36 | Correct | 215 ms | 4332 KB | correct |
37 | Correct | 18 ms | 4332 KB | correct |
38 | Correct | 332 ms | 4332 KB | correct |
39 | Correct | 266 ms | 4332 KB | correct |
40 | Correct | 216 ms | 4332 KB | correct |
41 | Correct | 334 ms | 4332 KB | correct |
42 | Correct | 337 ms | 4332 KB | correct |
43 | Correct | 155 ms | 4332 KB | correct |
44 | Correct | 136 ms | 4332 KB | correct |
45 | Correct | 159 ms | 4332 KB | correct |
46 | Correct | 116 ms | 4332 KB | correct |
47 | Correct | 49 ms | 4332 KB | correct |
48 | Correct | 9 ms | 4332 KB | correct |
49 | Correct | 19 ms | 4332 KB | correct |
50 | Correct | 51 ms | 4332 KB | correct |
51 | Correct | 157 ms | 4332 KB | correct |
52 | Correct | 127 ms | 4332 KB | correct |
53 | Correct | 114 ms | 4332 KB | correct |
54 | Correct | 161 ms | 4332 KB | correct |
55 | Correct | 167 ms | 4332 KB | correct |
56 | Correct | 163 ms | 4332 KB | correct |
57 | Correct | 188 ms | 4332 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4332 KB | correct |
2 | Correct | 5 ms | 4332 KB | correct |
3 | Incorrect | 251 ms | 6152 KB | WA in grader: NO |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3064 KB | correct |
2 | Correct | 6 ms | 3176 KB | correct |
3 | Correct | 7 ms | 3240 KB | correct |
4 | Correct | 8 ms | 3240 KB | correct |
5 | Correct | 6 ms | 3360 KB | correct |
6 | Correct | 7 ms | 3360 KB | correct |
7 | Correct | 7 ms | 3360 KB | correct |
8 | Correct | 6 ms | 3360 KB | correct |
9 | Correct | 7 ms | 3360 KB | correct |
10 | Correct | 7 ms | 3360 KB | correct |
11 | Correct | 7 ms | 3360 KB | correct |
12 | Correct | 6 ms | 3360 KB | correct |
13 | Correct | 6 ms | 3360 KB | correct |
14 | Correct | 12 ms | 3360 KB | correct |
15 | Correct | 11 ms | 3360 KB | correct |
16 | Correct | 13 ms | 3360 KB | correct |
17 | Correct | 10 ms | 3360 KB | correct |
18 | Correct | 8 ms | 3360 KB | correct |
19 | Correct | 10 ms | 3360 KB | correct |
20 | Correct | 9 ms | 3360 KB | correct |
21 | Correct | 10 ms | 3360 KB | correct |
22 | Correct | 8 ms | 3360 KB | correct |
23 | Correct | 9 ms | 3360 KB | correct |
24 | Correct | 9 ms | 3360 KB | correct |
25 | Correct | 10 ms | 3360 KB | correct |
26 | Correct | 9 ms | 3360 KB | correct |
27 | Correct | 9 ms | 3360 KB | correct |
28 | Correct | 8 ms | 3360 KB | correct |
29 | Correct | 7 ms | 3360 KB | correct |
30 | Correct | 8 ms | 3368 KB | correct |
31 | Correct | 9 ms | 3368 KB | correct |
32 | Correct | 10 ms | 3368 KB | correct |
33 | Correct | 11 ms | 3368 KB | correct |
34 | Correct | 349 ms | 4332 KB | correct |
35 | Correct | 313 ms | 4332 KB | correct |
36 | Correct | 215 ms | 4332 KB | correct |
37 | Correct | 18 ms | 4332 KB | correct |
38 | Correct | 332 ms | 4332 KB | correct |
39 | Correct | 266 ms | 4332 KB | correct |
40 | Correct | 216 ms | 4332 KB | correct |
41 | Correct | 334 ms | 4332 KB | correct |
42 | Correct | 337 ms | 4332 KB | correct |
43 | Correct | 155 ms | 4332 KB | correct |
44 | Correct | 136 ms | 4332 KB | correct |
45 | Correct | 159 ms | 4332 KB | correct |
46 | Correct | 116 ms | 4332 KB | correct |
47 | Correct | 49 ms | 4332 KB | correct |
48 | Correct | 9 ms | 4332 KB | correct |
49 | Correct | 19 ms | 4332 KB | correct |
50 | Correct | 51 ms | 4332 KB | correct |
51 | Correct | 157 ms | 4332 KB | correct |
52 | Correct | 127 ms | 4332 KB | correct |
53 | Correct | 114 ms | 4332 KB | correct |
54 | Correct | 161 ms | 4332 KB | correct |
55 | Correct | 167 ms | 4332 KB | correct |
56 | Correct | 163 ms | 4332 KB | correct |
57 | Correct | 188 ms | 4332 KB | correct |
58 | Correct | 6 ms | 4332 KB | correct |
59 | Correct | 5 ms | 4332 KB | correct |
60 | Incorrect | 251 ms | 6152 KB | WA in grader: NO |
61 | Halted | 0 ms | 0 KB | - |