# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
669799 |
2022-12-07T10:00:11 Z |
someone |
Toy Train (IOI17_train) |
C++14 |
|
7 ms |
1748 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];
vector<int> adj[N], ans, upd;
bool isA[N], isR[N], sent[N], mod[N];
inline void add(int i) {
if(mod[i])
return;
mod[i] = true;
upd.push_back(i);
}
void dfs(int i) {
if(sent[i])
return;
add(i);
sent[i] = true;
for(int j : adj[i]) {
add(j);
nbS[j]++;
if(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 i : id)
dfs(i);
for(int i = 0; i < sz; i++) {
if((isA[id[0]] && nbS[id[0]] > 0) || nbS[id[0]] == nb[id[0]])
id.push_back(id[0]);
id.pop_front();
}
for(int i : upd) {
nbS[i] = 0;
sent[i] = 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(sent[i]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 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 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Incorrect |
1 ms |
468 KB |
3rd lines differ - on the 4th token, expected: '0', found: '1' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1748 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 |
Correct |
6 ms |
1108 KB |
Output is correct |
2 |
Correct |
7 ms |
1108 KB |
Output is correct |
3 |
Incorrect |
7 ms |
1236 KB |
3rd lines differ - on the 108th token, expected: '0', found: '1' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1236 KB |
Output is correct |
2 |
Correct |
7 ms |
1492 KB |
Output is correct |
3 |
Correct |
6 ms |
1364 KB |
Output is correct |
4 |
Correct |
6 ms |
1236 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
3 ms |
852 KB |
Output is correct |
7 |
Correct |
4 ms |
980 KB |
Output is correct |
8 |
Correct |
4 ms |
980 KB |
Output is correct |
9 |
Correct |
6 ms |
956 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
5 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
980 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |