# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
609188 |
2022-07-27T12:42:34 Z |
yanndev |
Toy Train (IOI17_train) |
C++17 |
|
145 ms |
1412 KB |
#include <bits/stdc++.h>
using namespace std;
const int MX = 5042;
int n;
int deg[MX];
int baseDeg[MX];
int nxt[2 * MX];
bool vis[MX];
bool vis2[MX];
bool isOk[MX];
bool isAlice[MX];
bool isCharge[MX];
vector<int> rgraph[MX];
vector<int> nodes {};
bool BFS() {
int start = 0;
int end = 0;
for (auto& i: nodes) {
deg[i] = baseDeg[i];
if (isCharge[i] && isOk[i])
nxt[end++] = i;
vis[i] = vis2[i] = false;
}
//cout << layer << ' ' << (int)nxt.size() << '\n';
while (start < end) {
auto cur = nxt[start++];
//cout << "cur is " << cur << '\n';
if (vis[cur])
continue;
vis[cur] = true;
for (auto& x: rgraph[cur]) {
if (!vis2[x] && ((--deg[x] == 0) || isAlice[x])) {
vis2[x] = true;
nxt[end++] = x;
}
}
}
vector<int> newNodes {};
bool ret = false;
for (auto& i: nodes) {
if (isOk[i] && !vis2[i]) {
isOk[i] = false;
ret = true;
} else if (isOk[i]) {
newNodes.push_back(i);
}
}
nodes = newNodes;
return ret;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = (int)a.size();
for (int i = 0; i < (int)u.size(); i++) {
rgraph[v[i]].push_back(u[i]);
baseDeg[u[i]]++;
}
for (int i = 0; i < n; i++) {
isAlice[i] = a[i];
isCharge[i] = r[i];
isOk[i] = true;
nodes.push_back(i);
}
while (BFS());
vector<int> ans (n);
for (int i = 0; i < n; i++)
ans[i] = isOk[i];
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
980 KB |
Output is correct |
2 |
Correct |
6 ms |
980 KB |
Output is correct |
3 |
Correct |
5 ms |
984 KB |
Output is correct |
4 |
Correct |
5 ms |
980 KB |
Output is correct |
5 |
Correct |
5 ms |
980 KB |
Output is correct |
6 |
Correct |
5 ms |
980 KB |
Output is correct |
7 |
Correct |
4 ms |
948 KB |
Output is correct |
8 |
Correct |
5 ms |
984 KB |
Output is correct |
9 |
Correct |
4 ms |
964 KB |
Output is correct |
10 |
Correct |
4 ms |
852 KB |
Output is correct |
11 |
Correct |
3 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Incorrect |
1 ms |
424 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 |
Correct |
56 ms |
1412 KB |
Output is correct |
2 |
Correct |
93 ms |
1396 KB |
Output is correct |
3 |
Correct |
113 ms |
1364 KB |
Output is correct |
4 |
Correct |
7 ms |
1364 KB |
Output is correct |
5 |
Correct |
8 ms |
1364 KB |
Output is correct |
6 |
Correct |
7 ms |
1364 KB |
Output is correct |
7 |
Correct |
7 ms |
1332 KB |
Output is correct |
8 |
Correct |
6 ms |
1364 KB |
Output is correct |
9 |
Correct |
6 ms |
1236 KB |
Output is correct |
10 |
Correct |
6 ms |
1328 KB |
Output is correct |
11 |
Correct |
6 ms |
1236 KB |
Output is correct |
12 |
Correct |
5 ms |
1160 KB |
Output is correct |
13 |
Correct |
7 ms |
1364 KB |
Output is correct |
14 |
Correct |
7 ms |
1364 KB |
Output is correct |
15 |
Correct |
6 ms |
1332 KB |
Output is correct |
16 |
Correct |
7 ms |
1336 KB |
Output is correct |
17 |
Correct |
9 ms |
1364 KB |
Output is correct |
18 |
Correct |
145 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1236 KB |
Output is correct |
2 |
Correct |
6 ms |
1212 KB |
Output is correct |
3 |
Correct |
6 ms |
1236 KB |
Output is correct |
4 |
Correct |
7 ms |
1364 KB |
Output is correct |
5 |
Correct |
7 ms |
1364 KB |
Output is correct |
6 |
Correct |
6 ms |
1236 KB |
Output is correct |
7 |
Correct |
7 ms |
1236 KB |
Output is correct |
8 |
Correct |
7 ms |
1236 KB |
Output is correct |
9 |
Correct |
11 ms |
1236 KB |
Output is correct |
10 |
Correct |
6 ms |
1364 KB |
Output is correct |
11 |
Correct |
6 ms |
1364 KB |
Output is correct |
12 |
Correct |
7 ms |
1364 KB |
Output is correct |
13 |
Correct |
6 ms |
1336 KB |
Output is correct |
14 |
Correct |
6 ms |
1300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1336 KB |
Output is correct |
2 |
Correct |
6 ms |
1364 KB |
Output is correct |
3 |
Correct |
7 ms |
1332 KB |
Output is correct |
4 |
Correct |
6 ms |
1224 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
3 ms |
852 KB |
Output is correct |
7 |
Correct |
4 ms |
956 KB |
Output is correct |
8 |
Correct |
5 ms |
1108 KB |
Output is correct |
9 |
Correct |
4 ms |
1080 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
4 ms |
924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
980 KB |
Output is correct |
2 |
Correct |
6 ms |
980 KB |
Output is correct |
3 |
Correct |
5 ms |
984 KB |
Output is correct |
4 |
Correct |
5 ms |
980 KB |
Output is correct |
5 |
Correct |
5 ms |
980 KB |
Output is correct |
6 |
Correct |
5 ms |
980 KB |
Output is correct |
7 |
Correct |
4 ms |
948 KB |
Output is correct |
8 |
Correct |
5 ms |
984 KB |
Output is correct |
9 |
Correct |
4 ms |
964 KB |
Output is correct |
10 |
Correct |
4 ms |
852 KB |
Output is correct |
11 |
Correct |
3 ms |
852 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Incorrect |
1 ms |
424 KB |
3rd lines differ - on the 4th token, expected: '0', found: '1' |
16 |
Halted |
0 ms |
0 KB |
- |