# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
647475 | a_aguilo | Simurgh (IOI17_simurgh) | C++14 | 3074 ms | 308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |