# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
579127 | 2022-06-18T12:01:08 Z | ogibogi2004 | Simurgh (IOI17_simurgh) | C++14 | 24 ms | 6684 KB |
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; const int MAXN=256; vector<pair<int,int> >g[MAXN]; vector<int>g1[MAXN*MAXN]; vector<int>qe; bool vis[MAXN*MAXN]; void dfs(int u,int par) { vis[u]=1; for(auto xd:g[u]) { if(vis[xd.first])continue; qe.push_back(xd.second); dfs(xd.first,u); } } vector<vector<int>>comp; void dfs1(int u) { vis[u]=1; comp[comp.size()-1].push_back(u); for(auto xd:g1[u]) { if(vis[xd]==0) { dfs1(xd); } } } vector<int> find_roads(int n, vector<int> u, vector<int> v) { for(int i=0;i<u.size();i++) { g[u[i]].push_back({v[i],i}); g[v[i]].push_back({u[i],i}); } vector<int>royal; for(int i=0;i<n;i++) { //cout<<i<<endl; memset(vis,0,sizeof(vis)); vis[i]=1; qe.clear(); if(i==0) { dfs(1,-1); } else { dfs(0,-1); } //cout<<"?\n"; if(qe.size()<n-2) { for(int j=1;j<g[i].size();j++) { g1[g[i][j-1].second].push_back(g[i][j].second); g1[g[i][j].second].push_back(g[i][j-1].second); } } else { vector<pair<int,int> >edg; for(int j=0;j<g[i].size();j++) { qe.push_back(g[i][j].second); edg.push_back({count_common_roads(qe),g[i][j].second}); qe.pop_back(); } sort(edg.begin(),edg.end()); for(int j=1;j<edg.size();j++) { if(edg[j].first!=edg[j-1].first)continue; g1[edg[j].second].push_back(edg[j-1].second); g1[edg[j-1].second].push_back(edg[j].second); } } } memset(vis,0,sizeof(vis)); for(int i=0;i<u.size();i++) { if(vis[i]==0) { comp.push_back({}); dfs1(i); } } if(comp[0].size()==comp[1].size()) { if(count_common_roads(comp[0])==n-1)return comp[0]; else return comp[1]; } if(comp[0].size()==n-1)return comp[0]; return comp[1]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1856 KB | correct |
2 | Correct | 1 ms | 1852 KB | correct |
3 | Correct | 2 ms | 1876 KB | correct |
4 | Correct | 2 ms | 1876 KB | correct |
5 | Correct | 2 ms | 1876 KB | correct |
6 | Correct | 2 ms | 1876 KB | correct |
7 | Correct | 2 ms | 1876 KB | correct |
8 | Correct | 1 ms | 1876 KB | correct |
9 | Correct | 1 ms | 1876 KB | correct |
10 | Correct | 1 ms | 1876 KB | correct |
11 | Correct | 1 ms | 1852 KB | correct |
12 | Correct | 2 ms | 1852 KB | correct |
13 | Correct | 2 ms | 1876 KB | correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1856 KB | correct |
2 | Correct | 1 ms | 1852 KB | correct |
3 | Correct | 2 ms | 1876 KB | correct |
4 | Correct | 2 ms | 1876 KB | correct |
5 | Correct | 2 ms | 1876 KB | correct |
6 | Correct | 2 ms | 1876 KB | correct |
7 | Correct | 2 ms | 1876 KB | correct |
8 | Correct | 1 ms | 1876 KB | correct |
9 | Correct | 1 ms | 1876 KB | correct |
10 | Correct | 1 ms | 1876 KB | correct |
11 | Correct | 1 ms | 1852 KB | correct |
12 | Correct | 2 ms | 1852 KB | correct |
13 | Correct | 2 ms | 1876 KB | correct |
14 | Correct | 4 ms | 2004 KB | correct |
15 | Correct | 5 ms | 2004 KB | correct |
16 | Correct | 6 ms | 2004 KB | correct |
17 | Correct | 4 ms | 1984 KB | correct |
18 | Correct | 3 ms | 1852 KB | correct |
19 | Correct | 5 ms | 2004 KB | correct |
20 | Correct | 5 ms | 1928 KB | correct |
21 | Correct | 4 ms | 1980 KB | correct |
22 | Runtime error | 7 ms | 3924 KB | Execution killed with signal 6 |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1856 KB | correct |
2 | Correct | 1 ms | 1852 KB | correct |
3 | Correct | 2 ms | 1876 KB | correct |
4 | Correct | 2 ms | 1876 KB | correct |
5 | Correct | 2 ms | 1876 KB | correct |
6 | Correct | 2 ms | 1876 KB | correct |
7 | Correct | 2 ms | 1876 KB | correct |
8 | Correct | 1 ms | 1876 KB | correct |
9 | Correct | 1 ms | 1876 KB | correct |
10 | Correct | 1 ms | 1876 KB | correct |
11 | Correct | 1 ms | 1852 KB | correct |
12 | Correct | 2 ms | 1852 KB | correct |
13 | Correct | 2 ms | 1876 KB | correct |
14 | Correct | 4 ms | 2004 KB | correct |
15 | Correct | 5 ms | 2004 KB | correct |
16 | Correct | 6 ms | 2004 KB | correct |
17 | Correct | 4 ms | 1984 KB | correct |
18 | Correct | 3 ms | 1852 KB | correct |
19 | Correct | 5 ms | 2004 KB | correct |
20 | Correct | 5 ms | 1928 KB | correct |
21 | Correct | 4 ms | 1980 KB | correct |
22 | Runtime error | 7 ms | 3924 KB | Execution killed with signal 6 |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1876 KB | correct |
2 | Correct | 2 ms | 1876 KB | correct |
3 | Runtime error | 24 ms | 6684 KB | Execution killed with signal 11 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1856 KB | correct |
2 | Correct | 1 ms | 1852 KB | correct |
3 | Correct | 2 ms | 1876 KB | correct |
4 | Correct | 2 ms | 1876 KB | correct |
5 | Correct | 2 ms | 1876 KB | correct |
6 | Correct | 2 ms | 1876 KB | correct |
7 | Correct | 2 ms | 1876 KB | correct |
8 | Correct | 1 ms | 1876 KB | correct |
9 | Correct | 1 ms | 1876 KB | correct |
10 | Correct | 1 ms | 1876 KB | correct |
11 | Correct | 1 ms | 1852 KB | correct |
12 | Correct | 2 ms | 1852 KB | correct |
13 | Correct | 2 ms | 1876 KB | correct |
14 | Correct | 4 ms | 2004 KB | correct |
15 | Correct | 5 ms | 2004 KB | correct |
16 | Correct | 6 ms | 2004 KB | correct |
17 | Correct | 4 ms | 1984 KB | correct |
18 | Correct | 3 ms | 1852 KB | correct |
19 | Correct | 5 ms | 2004 KB | correct |
20 | Correct | 5 ms | 1928 KB | correct |
21 | Correct | 4 ms | 1980 KB | correct |
22 | Runtime error | 7 ms | 3924 KB | Execution killed with signal 6 |
23 | Halted | 0 ms | 0 KB | - |