# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60599 | 2018-07-24T11:26:26 Z | Tenuun | Simurgh (IOI17_simurgh) | C++17 | 3 ms | 512 KB |
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; vector<pair<int, int> >adj[241]; vector<int>t; bool vis[241]; void DFS(int u, int p){ vis[u]=true; for(auto v:adj[u]){ if(v.first!=p && vis[v.first]==false){ vis[v.first]=true; if(p!=-1) t.push_back(v.second); DFS(v.first, u); } } } int calc(int u){ int mx=-1, p, tmp; for(auto v:adj[u]){ t.push_back(v.second); tmp=count_common_roads(t);; if(tmp>mx){ mx=tmp; p=v.second; } t.pop_back(); } return p; } vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { bool check[n]={false}; int f, ind=0; vector<int> res(n - 1); for(int i=0; i<u.size(); i++){ adj[u[i]].push_back({v[i], i}); adj[v[i]].push_back({u[i], i}); } for(int i=0; i<n; i++){ if(check[i]) continue; memset(vis, false, sizeof vis); t.clear(); DFS(i, -1); f=calc(i); check[u[f]]=true; check[v[f]]=true; res[ind++]=f; } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 252 KB | correct |
2 | Incorrect | 2 ms | 356 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 252 KB | correct |
2 | Incorrect | 2 ms | 356 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 252 KB | correct |
2 | Incorrect | 2 ms | 356 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | correct |
2 | Incorrect | 3 ms | 512 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 252 KB | correct |
2 | Incorrect | 2 ms | 356 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |