# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
584685 |
2022-06-27T19:47:27 Z |
1ne |
Toy Train (IOI17_train) |
C++14 |
|
1010 ms |
1484 KB |
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
int n = (int)a.size();
int m = (int)u.size();
vector<int>ans(n);
vector<vector<int>>adj(n);
for (int i = 0;i<m;++i){
adj[u[i]].push_back(v[i]);
}
vector<bool>in_cycle(n,false);
vector<bool>visited(n,false);
for (int i = 0;i<n;++i){
if (!r[i])continue;
vector<int>bucket;
for (int j = 0;j<n;++j)visited[j] = false;
function<void(int)>dfs = [&](int u){
if (visited[u]){
if (u == i){
for (auto x:bucket){
in_cycle[x] = true;
}
}
return;
}
bucket.push_back(u);
visited[u] = true;
for (auto x:adj[u]){
dfs(x);
}
bucket.pop_back();
};
dfs(i);
}
for (int i = 0;i<n;++i){
visited[i] = false;
}
for (int i = 0;i<n;++i){
if (in_cycle[i]){
visited[i] = true;
ans[i] = true;
}
}
function<int(int)>dfs2 = [&](int u){
if (visited[u])return ans[u];
visited[u] = true;
int v = 0;
for (auto x:adj[u]){
v|=dfs2(x);
}
return ans[u] = v;
};
for (int i = 0;i<n;++i){
if (!visited[i]){
ans[i] = dfs2(i);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
201 ms |
1124 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1256 KB |
Output is correct |
2 |
Correct |
46 ms |
1192 KB |
Output is correct |
3 |
Correct |
94 ms |
1248 KB |
Output is correct |
4 |
Correct |
378 ms |
1236 KB |
Output is correct |
5 |
Correct |
55 ms |
1484 KB |
Output is correct |
6 |
Correct |
94 ms |
1272 KB |
Output is correct |
7 |
Correct |
308 ms |
1236 KB |
Output is correct |
8 |
Incorrect |
6 ms |
1212 KB |
3rd lines differ - on the 305th token, expected: '1', found: '0' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1010 ms |
1064 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
1216 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
201 ms |
1124 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |