# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
669627 |
2022-12-06T23:27:44 Z |
someone |
Toy Train (IOI17_train) |
C++14 |
|
8 ms |
1616 KB |
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 42, INF = 1e9;
int n, m, nb[N], nbS[N];
bool isA[N], isR[N], sent[N];
vector<int> adj[N], ans, upd;
void dfs(int i) {
if(sent[i])
return;
sent[i] = true;
for(int j : adj[i]) {
nbS[j]++;
if(isA[j] || (!isA[j] && nbS[j] == nb[j]))
dfs(j);
}
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = (int)a.size();
m = (int)u.size();
for(int i = 0; i < n; i++)
isA[i] = (a[i] == 1),
isR[i] = (r[i] == 1);
for(int i = 0; i < m; i++) {
nb[u[i]]++;
adj[v[i]].push_back(u[i]);
}
deque<int> id;
for(int i = 0; i < n; i++)
if(r[i])
id.push_back(i);
int sz = (int)id.size();
while(true) {
for(int j : id)
dfs(j);
for(int i = 0; i < sz; i++) {
if((isA[id[0]] && nbS[id[0]] > 0) || (!isA[id[0]] && nbS[id[0]] == nb[id[0]]))
id.push_back(id[0]);
id.pop_front();
}
for(int j : upd) {
nbS[j] = 0;
sent[j] = false;
}
upd.clear();
if(sz == (int)id.size())
break;
sz = id.size();
}
for(int i : id)
dfs(i);
for(int i = 0; i < n; i++)
ans.push_back(((isA[i] && nbS[i] > 0) || (!isA[i] && nbS[i] == nb[i])));
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
980 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 |
1 ms |
468 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 |
Incorrect |
6 ms |
1492 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 |
5 ms |
1108 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 |
Correct |
7 ms |
1248 KB |
Output is correct |
2 |
Correct |
7 ms |
1616 KB |
Output is correct |
3 |
Correct |
7 ms |
1504 KB |
Output is correct |
4 |
Correct |
8 ms |
1364 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
4 ms |
936 KB |
Output is correct |
7 |
Correct |
4 ms |
1072 KB |
Output is correct |
8 |
Incorrect |
5 ms |
1108 KB |
3rd lines differ - on the 5th token, expected: '0', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
980 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |