# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647476 | 2022-10-02T17:16:46 Z | a_aguilo | Simurgh (IOI17_simurgh) | C++14 | 3000 ms | 376 KB |
#include "simurgh.h" #include<bits/stdc++.h> using namespace std; vector<int> padre; int N; vector<int> choices; int raiz(int nodo){ if(padre[nodo] == nodo) return nodo; return raiz(padre[nodo]); } bool getTree(int pos, vector<pair<int, int>>& edges){ //cout << pos << endl; if((choices.size()+edges.size()-pos) < (N-1)) return false; if(pos == edges.size()){ if(choices.size() == N-1){ //cout << "submit" << endl; //print(choices); if(count_common_roads(choices) == N-1) { //cout << "yes "<< endl; return true; } return false; } else return false; } pair<int, int> actEdge = edges[pos]; int a = actEdge.first; int b = actEdge.second; int rootA = raiz(a); int rootB = raiz(b); if (getTree(pos+1, edges)) return true; else if (rootA!=rootB) { padre[rootB] = rootA; choices.push_back(pos); bool ret = getTree(pos+1, edges); padre[rootB] = rootB; if(ret) return true; choices.pop_back(); } return false; } vector<int> find_roads(int n, vector<int> u, vector<int> v) { N = n; vector<pair<int, int>> edges(u.size()); choices = vector<int>(); for(int i = 0; i < u.size(); ++i){ edges[i] = {u[i], v[i]}; } padre = vector<int>(n); for(int i = 0; i < n; ++i) padre[i] = i; getTree(0, edges); return choices; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 4 ms | 212 KB | correct |
3 | Correct | 3 ms | 212 KB | correct |
4 | Correct | 1 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 1 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 256 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 2 ms | 212 KB | correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 4 ms | 212 KB | correct |
3 | Correct | 3 ms | 212 KB | correct |
4 | Correct | 1 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 1 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 256 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 2 ms | 212 KB | correct |
14 | Execution timed out | 3088 ms | 376 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 4 ms | 212 KB | correct |
3 | Correct | 3 ms | 212 KB | correct |
4 | Correct | 1 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 1 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 256 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 2 ms | 212 KB | correct |
14 | Execution timed out | 3088 ms | 376 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | correct |
2 | Incorrect | 7 ms | 212 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | correct |
2 | Correct | 4 ms | 212 KB | correct |
3 | Correct | 3 ms | 212 KB | correct |
4 | Correct | 1 ms | 212 KB | correct |
5 | Correct | 0 ms | 212 KB | correct |
6 | Correct | 1 ms | 212 KB | correct |
7 | Correct | 0 ms | 212 KB | correct |
8 | Correct | 0 ms | 256 KB | correct |
9 | Correct | 0 ms | 212 KB | correct |
10 | Correct | 0 ms | 212 KB | correct |
11 | Correct | 0 ms | 212 KB | correct |
12 | Correct | 1 ms | 212 KB | correct |
13 | Correct | 2 ms | 212 KB | correct |
14 | Execution timed out | 3088 ms | 376 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |