# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
428642 |
2021-06-15T13:25:13 Z |
vanic |
Toy Train (IOI17_train) |
C++14 |
|
8 ms |
1304 KB |
#include "train.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn=5005;
int n, m;
vector < int > ms[maxn];
int charge[maxn];
bool tko[maxn];
bool bio[maxn];
vector < int > sol;
int poc;
int dfs(int x){
if(x==poc){
return 1;
}
if(bio[x]){
return sol[x];
}
bio[x]=1;
for(int i=0; i<(int)ms[x].size(); i++){
sol[x]|=dfs(ms[x][i]);
}
return sol[x];
}
vector < int > who_wins(vector < int > a, vector < int > r, vector < int > u, vector < int > v) {
n=a.size();
m=u.size();
for(int i=0; i<n; i++){
tko[i]=a[i];
charge[i]=r[i];
}
for(int i=0; i<m; i++){
ms[u[i]].push_back(v[i]);
}
sol.resize(n, 0);
for(int i=0; i<n; i++){
if(charge[i]){
poc=i;
dfs(i);
}
}
bool p=1;
while(p){
p=0;
for(int i=0; i<n; i++){
if(sol[i]){
continue;
}
for(int j=0; j<(int)ms[i].size(); j++){
if(sol[ms[i][j]]){
sol[i]=1;
p=1;
break;
}
}
}
}
return sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
844 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1020 KB |
Output is correct |
2 |
Correct |
7 ms |
1196 KB |
Output is correct |
3 |
Correct |
7 ms |
1304 KB |
Output is correct |
4 |
Incorrect |
8 ms |
1228 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
972 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
992 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
844 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |