# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
302074 |
2020-09-18T12:22:01 Z |
TMJN |
Simurgh (IOI17_simurgh) |
C++17 |
|
71 ms |
512 KB |
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
int N,T[10];
vector<int>U,V,res;
bool B[30];
int par(int x){
if(T[x]==x)return x;
return T[x]=par(T[x]);
}
void uni(int x,int y){
x=par(x);
y=par(y);
T[x]=y;
}
void dfs(int x,int t){
if(t==N-1){
for(int i=0;i<N;i++){
T[i]=i;
}
for(int i=0;i<U.size();i++){
if(B[i]){
uni(U[i],V[i]);
}
}
bool f=true;
for(int i=0;i<N-1;i++){
if(par(i)!=par(i+1))f=false;
}
if(f){
vector<int>v;
for(int i=0;i<U.size();i++){
if(B[i]){
v.push_back(i);
}
}
if(count_common_roads(v)==N-1){
res=v;
}
}
}
else{
for(int i=x;i<U.size();i++){
B[i]=true;
dfs(i+1,t+1);
B[i]=false;
}
}
}
vector<int>find_roads(int n,vector<int>u,vector<int>v){
N=n;
U=u;
V=v;
dfs(0,0);
return res;
}
Compilation message
simurgh.cpp: In function 'void dfs(int, int)':
simurgh.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int i=0;i<U.size();i++){
| ~^~~~~~~~~
simurgh.cpp:36:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i=0;i<U.size();i++){
| ~^~~~~~~~~
simurgh.cpp:47:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i=x;i<U.size();i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
256 KB |
correct |
2 |
Correct |
18 ms |
384 KB |
correct |
3 |
Correct |
19 ms |
376 KB |
correct |
4 |
Correct |
1 ms |
256 KB |
correct |
5 |
Correct |
1 ms |
256 KB |
correct |
6 |
Correct |
3 ms |
256 KB |
correct |
7 |
Correct |
1 ms |
256 KB |
correct |
8 |
Correct |
1 ms |
256 KB |
correct |
9 |
Correct |
1 ms |
256 KB |
correct |
10 |
Correct |
1 ms |
256 KB |
correct |
11 |
Correct |
1 ms |
256 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
19 ms |
256 KB |
correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
256 KB |
correct |
2 |
Correct |
18 ms |
384 KB |
correct |
3 |
Correct |
19 ms |
376 KB |
correct |
4 |
Correct |
1 ms |
256 KB |
correct |
5 |
Correct |
1 ms |
256 KB |
correct |
6 |
Correct |
3 ms |
256 KB |
correct |
7 |
Correct |
1 ms |
256 KB |
correct |
8 |
Correct |
1 ms |
256 KB |
correct |
9 |
Correct |
1 ms |
256 KB |
correct |
10 |
Correct |
1 ms |
256 KB |
correct |
11 |
Correct |
1 ms |
256 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
19 ms |
256 KB |
correct |
14 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
256 KB |
correct |
2 |
Correct |
18 ms |
384 KB |
correct |
3 |
Correct |
19 ms |
376 KB |
correct |
4 |
Correct |
1 ms |
256 KB |
correct |
5 |
Correct |
1 ms |
256 KB |
correct |
6 |
Correct |
3 ms |
256 KB |
correct |
7 |
Correct |
1 ms |
256 KB |
correct |
8 |
Correct |
1 ms |
256 KB |
correct |
9 |
Correct |
1 ms |
256 KB |
correct |
10 |
Correct |
1 ms |
256 KB |
correct |
11 |
Correct |
1 ms |
256 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
19 ms |
256 KB |
correct |
14 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
correct |
2 |
Runtime error |
71 ms |
504 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
256 KB |
correct |
2 |
Correct |
18 ms |
384 KB |
correct |
3 |
Correct |
19 ms |
376 KB |
correct |
4 |
Correct |
1 ms |
256 KB |
correct |
5 |
Correct |
1 ms |
256 KB |
correct |
6 |
Correct |
3 ms |
256 KB |
correct |
7 |
Correct |
1 ms |
256 KB |
correct |
8 |
Correct |
1 ms |
256 KB |
correct |
9 |
Correct |
1 ms |
256 KB |
correct |
10 |
Correct |
1 ms |
256 KB |
correct |
11 |
Correct |
1 ms |
256 KB |
correct |
12 |
Correct |
2 ms |
256 KB |
correct |
13 |
Correct |
19 ms |
256 KB |
correct |
14 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |