# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
436490 | 2021-06-24T14:21:51 Z | mat_v | Simurgh (IOI17_simurgh) | C++14 | 308 ms | 5236 KB |
#include "simurgh.h" #include <bits/stdc++.h> #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i)) #define pb push_back #define pii pair<int,int> #define xx first #define yy second using namespace std; pii ed[500005]; int _n; int disc[505]; bool bio[505]; vector<pii> graf[505]; pii cale[505]; vector<pii> gore[505]; int br=1; int odg[500005]; int out[505]; void dfs(int x){ disc[x] = br; bio[x] = 1; for(auto c:graf[x]){ if(bio[c.xx])continue; cale[c.xx] = {x,c.yy}; br++; dfs(c.xx); } br++; out[x] = br; } set<int> s; int poc; int dsu[505]; int finddsu(int x){ if(x == dsu[x])return x; return dsu[x] = finddsu(dsu[x]); } int pitaj(){ vector<int> r; for(auto c:s)r.pb(c); ff(i,0,_n-1)dsu[i] = i; for(auto c:r){ if(finddsu(ed[c].xx) == finddsu(ed[c].yy))assert(false); dsu[finddsu(ed[c].xx)] = finddsu(ed[c].yy); } return count_common_roads(r); } vector<pii> sad; vector<int> ans; vector<int> imam; void resi(int x){ for(auto c:graf[x]){ if(cale[c.xx].xx == x)resi(c.xx); } if(x == 0)return; int i = x; sad.clear(); int mks = poc; sad.pb({poc,cale[i].yy}); bool da = 0; for(auto c:gore[i]){ s.erase(cale[i].yy); s.insert(c.yy); int sta = pitaj(); if(sta != poc)da = 1; mks = max(mks, sta); sad.pb({sta, c.yy}); s.erase(c.yy); s.insert(cale[i].yy); } if(da){ for(auto c:sad){ if(c.xx == mks){ ans.pb(c.yy); odg[c.yy] = 1; } } } else{ bool ima = 0; for(auto c:imam){ int mn = min(disc[ed[c].xx], disc[ed[c].yy]); int ms = max(disc[ed[c].xx], disc[ed[c].yy]); if(mn < disc[x] && ms > disc[x] && ms < out[x]){ ima = 1; s.erase(cale[i].yy); s.insert(c); int kurac = pitaj(); if(kurac == poc){ odg[cale[i].yy] = odg[c]; } else if(kurac < poc)odg[cale[i].yy] = 1; s.erase(c); s.insert(cale[i].yy); break; } } if(!ima)odg[cale[i].yy] = 1; if(odg[cale[i].yy] == 1){ for(auto c:sad){ odg[c.yy] = 1; ans.pb(c.yy); } } } for(auto c:gore[i])imam.pb(c.yy); } std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { std::vector<int> r(n - 1); int m = u.size(); _n = n; ff(i,0,m - 1){ ed[i] = {u[i],v[i]}; graf[u[i]].pb({v[i],i}); graf[v[i]].pb({u[i],i}); } ff(i,0,n - 1)cale[i].xx = -1; dfs(0); ff(i,0,m - 1){ int prvi = u[i]; int drugi = v[i]; if(cale[prvi].xx == drugi || cale[drugi].xx == prvi)continue; if(disc[prvi] < disc[drugi]){ gore[drugi].pb({prvi,i}); } else gore[prvi].pb({drugi,i}); } ff(i,0,m - 1){ if(cale[u[i]].xx == v[i] || cale[v[i]].xx == u[i])s.insert(i); } //cout << "kurcina\n"; poc = pitaj(); resi(0); int pp = ans.size(); //assert(pp == n-1); return ans; } /* 4 6 0 1 0 2 0 3 1 2 1 3 2 3 0 1 5 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | correct |
2 | Correct | 1 ms | 332 KB | correct |
3 | Correct | 1 ms | 332 KB | correct |
4 | Correct | 1 ms | 332 KB | correct |
5 | Correct | 1 ms | 332 KB | correct |
6 | Correct | 1 ms | 332 KB | correct |
7 | Correct | 0 ms | 332 KB | correct |
8 | Correct | 1 ms | 332 KB | correct |
9 | Correct | 1 ms | 332 KB | correct |
10 | Correct | 1 ms | 332 KB | correct |
11 | Correct | 1 ms | 332 KB | correct |
12 | Correct | 1 ms | 332 KB | correct |
13 | Correct | 1 ms | 332 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | correct |
2 | Correct | 1 ms | 332 KB | correct |
3 | Correct | 1 ms | 332 KB | correct |
4 | Correct | 1 ms | 332 KB | correct |
5 | Correct | 1 ms | 332 KB | correct |
6 | Correct | 1 ms | 332 KB | correct |
7 | Correct | 0 ms | 332 KB | correct |
8 | Correct | 1 ms | 332 KB | correct |
9 | Correct | 1 ms | 332 KB | correct |
10 | Correct | 1 ms | 332 KB | correct |
11 | Correct | 1 ms | 332 KB | correct |
12 | Correct | 1 ms | 332 KB | correct |
13 | Correct | 1 ms | 332 KB | correct |
14 | Correct | 4 ms | 424 KB | correct |
15 | Correct | 4 ms | 332 KB | correct |
16 | Correct | 5 ms | 424 KB | correct |
17 | Correct | 4 ms | 432 KB | correct |
18 | Correct | 2 ms | 332 KB | correct |
19 | Correct | 4 ms | 332 KB | correct |
20 | Correct | 3 ms | 332 KB | correct |
21 | Correct | 3 ms | 332 KB | correct |
22 | Correct | 3 ms | 332 KB | correct |
23 | Correct | 2 ms | 332 KB | correct |
24 | Correct | 2 ms | 332 KB | correct |
25 | Correct | 1 ms | 332 KB | correct |
26 | Correct | 2 ms | 332 KB | correct |
27 | Correct | 2 ms | 332 KB | correct |
28 | Correct | 2 ms | 372 KB | correct |
29 | Correct | 1 ms | 332 KB | correct |
30 | Correct | 2 ms | 332 KB | correct |
31 | Correct | 2 ms | 332 KB | correct |
32 | Correct | 2 ms | 332 KB | correct |
33 | Correct | 3 ms | 292 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | correct |
2 | Correct | 1 ms | 332 KB | correct |
3 | Correct | 1 ms | 332 KB | correct |
4 | Correct | 1 ms | 332 KB | correct |
5 | Correct | 1 ms | 332 KB | correct |
6 | Correct | 1 ms | 332 KB | correct |
7 | Correct | 0 ms | 332 KB | correct |
8 | Correct | 1 ms | 332 KB | correct |
9 | Correct | 1 ms | 332 KB | correct |
10 | Correct | 1 ms | 332 KB | correct |
11 | Correct | 1 ms | 332 KB | correct |
12 | Correct | 1 ms | 332 KB | correct |
13 | Correct | 1 ms | 332 KB | correct |
14 | Correct | 4 ms | 424 KB | correct |
15 | Correct | 4 ms | 332 KB | correct |
16 | Correct | 5 ms | 424 KB | correct |
17 | Correct | 4 ms | 432 KB | correct |
18 | Correct | 2 ms | 332 KB | correct |
19 | Correct | 4 ms | 332 KB | correct |
20 | Correct | 3 ms | 332 KB | correct |
21 | Correct | 3 ms | 332 KB | correct |
22 | Correct | 3 ms | 332 KB | correct |
23 | Correct | 2 ms | 332 KB | correct |
24 | Correct | 2 ms | 332 KB | correct |
25 | Correct | 1 ms | 332 KB | correct |
26 | Correct | 2 ms | 332 KB | correct |
27 | Correct | 2 ms | 332 KB | correct |
28 | Correct | 2 ms | 372 KB | correct |
29 | Correct | 1 ms | 332 KB | correct |
30 | Correct | 2 ms | 332 KB | correct |
31 | Correct | 2 ms | 332 KB | correct |
32 | Correct | 2 ms | 332 KB | correct |
33 | Correct | 3 ms | 292 KB | correct |
34 | Correct | 294 ms | 2440 KB | correct |
35 | Correct | 291 ms | 2348 KB | correct |
36 | Correct | 197 ms | 1988 KB | correct |
37 | Correct | 12 ms | 460 KB | correct |
38 | Correct | 297 ms | 2544 KB | correct |
39 | Correct | 250 ms | 2244 KB | correct |
40 | Correct | 195 ms | 1932 KB | correct |
41 | Correct | 304 ms | 2536 KB | correct |
42 | Correct | 308 ms | 2436 KB | correct |
43 | Correct | 168 ms | 1480 KB | correct |
44 | Correct | 136 ms | 1352 KB | correct |
45 | Correct | 154 ms | 1252 KB | correct |
46 | Correct | 113 ms | 1124 KB | correct |
47 | Correct | 51 ms | 716 KB | correct |
48 | Correct | 4 ms | 332 KB | correct |
49 | Correct | 14 ms | 476 KB | correct |
50 | Correct | 52 ms | 736 KB | correct |
51 | Correct | 153 ms | 1444 KB | correct |
52 | Correct | 130 ms | 1140 KB | correct |
53 | Correct | 130 ms | 1092 KB | correct |
54 | Correct | 163 ms | 1576 KB | correct |
55 | Correct | 145 ms | 1348 KB | correct |
56 | Correct | 142 ms | 1280 KB | correct |
57 | Correct | 144 ms | 1352 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | correct |
2 | Correct | 1 ms | 332 KB | correct |
3 | Incorrect | 241 ms | 5236 KB | WA in grader: NO |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | correct |
2 | Correct | 1 ms | 332 KB | correct |
3 | Correct | 1 ms | 332 KB | correct |
4 | Correct | 1 ms | 332 KB | correct |
5 | Correct | 1 ms | 332 KB | correct |
6 | Correct | 1 ms | 332 KB | correct |
7 | Correct | 0 ms | 332 KB | correct |
8 | Correct | 1 ms | 332 KB | correct |
9 | Correct | 1 ms | 332 KB | correct |
10 | Correct | 1 ms | 332 KB | correct |
11 | Correct | 1 ms | 332 KB | correct |
12 | Correct | 1 ms | 332 KB | correct |
13 | Correct | 1 ms | 332 KB | correct |
14 | Correct | 4 ms | 424 KB | correct |
15 | Correct | 4 ms | 332 KB | correct |
16 | Correct | 5 ms | 424 KB | correct |
17 | Correct | 4 ms | 432 KB | correct |
18 | Correct | 2 ms | 332 KB | correct |
19 | Correct | 4 ms | 332 KB | correct |
20 | Correct | 3 ms | 332 KB | correct |
21 | Correct | 3 ms | 332 KB | correct |
22 | Correct | 3 ms | 332 KB | correct |
23 | Correct | 2 ms | 332 KB | correct |
24 | Correct | 2 ms | 332 KB | correct |
25 | Correct | 1 ms | 332 KB | correct |
26 | Correct | 2 ms | 332 KB | correct |
27 | Correct | 2 ms | 332 KB | correct |
28 | Correct | 2 ms | 372 KB | correct |
29 | Correct | 1 ms | 332 KB | correct |
30 | Correct | 2 ms | 332 KB | correct |
31 | Correct | 2 ms | 332 KB | correct |
32 | Correct | 2 ms | 332 KB | correct |
33 | Correct | 3 ms | 292 KB | correct |
34 | Correct | 294 ms | 2440 KB | correct |
35 | Correct | 291 ms | 2348 KB | correct |
36 | Correct | 197 ms | 1988 KB | correct |
37 | Correct | 12 ms | 460 KB | correct |
38 | Correct | 297 ms | 2544 KB | correct |
39 | Correct | 250 ms | 2244 KB | correct |
40 | Correct | 195 ms | 1932 KB | correct |
41 | Correct | 304 ms | 2536 KB | correct |
42 | Correct | 308 ms | 2436 KB | correct |
43 | Correct | 168 ms | 1480 KB | correct |
44 | Correct | 136 ms | 1352 KB | correct |
45 | Correct | 154 ms | 1252 KB | correct |
46 | Correct | 113 ms | 1124 KB | correct |
47 | Correct | 51 ms | 716 KB | correct |
48 | Correct | 4 ms | 332 KB | correct |
49 | Correct | 14 ms | 476 KB | correct |
50 | Correct | 52 ms | 736 KB | correct |
51 | Correct | 153 ms | 1444 KB | correct |
52 | Correct | 130 ms | 1140 KB | correct |
53 | Correct | 130 ms | 1092 KB | correct |
54 | Correct | 163 ms | 1576 KB | correct |
55 | Correct | 145 ms | 1348 KB | correct |
56 | Correct | 142 ms | 1280 KB | correct |
57 | Correct | 144 ms | 1352 KB | correct |
58 | Correct | 1 ms | 332 KB | correct |
59 | Correct | 1 ms | 332 KB | correct |
60 | Incorrect | 241 ms | 5236 KB | WA in grader: NO |
61 | Halted | 0 ms | 0 KB | - |