# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
390280 |
2021-04-15T18:14:56 Z |
Keshi |
Toy Train (IOI17_train) |
C++17 |
|
363 ms |
55708 KB |
//In the name of God
#include <bits/stdc++.h>
#include "train.h"
using namespace std;
typedef int ll;
typedef pair<ll, ll> pll;
const ll maxn = 5100;
const ll mod = 1e9 + 7;
const ll inf = 1e9;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll n, m;
vector<ll> g[maxn], gp[maxn];
ll ok[maxn][maxn], cnt[maxn], q[maxn], w[maxn];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> v, vector<int> u){
n = Sz(a);
m = Sz(v);
vector<int> res(n), res2(n);
for(ll i = 0; i < m; i++){
g[v[i]].pb(u[i]);
gp[u[i]].pb(v[i]);
}
/*res2[n - 1] = r[n - 1];
for(ll i = n - 1; i--;){
res2[i] = res2[i + 1];
if(Sz(g[i]) == 1) continue;
if(a[i]) res2[i] |= r[i];
else res2[i] &= r[i];
}*/
for(ll i = 0; i < n; i++){
if(!r[i]) continue;
fill(cnt, cnt + maxn, 0);
ll l = 0, r = 0;
ok[i][q[r++] = i] = 1;
while(l < r){
ll v = q[l++];
for(ll u : gp[v]){
cnt[u]++;
if(ok[i][u]) continue;
if(a[u]) ok[i][q[r++] = u] = 1;
else if(cnt[u] == Sz(g[u])) ok[i][q[r++] = u] = 1;
}
}
if(a[i]){
if(cnt[i]) w[i] = 1;
}
else{
if(cnt[i] == Sz(g[i])) w[i] = 1;
}
}
fill(cnt, cnt + n, 0);
ll l = 0, qr = 0;
for(ll i = 0; i < n; i++){
if(w[i]){
res[q[qr++] = i] = 1;
continue;
}
if(!r[i]) continue;
for(ll j : g[i]){
if(i == j) cnt[i]++;
}
if(cnt[i] == Sz(g[i]) || (a[i] && cnt[i])) res[q[qr++] = i] = 1;
}
while(l < qr){
ll v = q[l++];
for(ll u : gp[v]){
cnt[u]++;
if(res[u]) continue;
if(a[u] || cnt[u] == Sz(g[u])) res[q[qr++] = u] = 1;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
11472 KB |
Output is correct |
2 |
Correct |
18 ms |
11504 KB |
Output is correct |
3 |
Correct |
18 ms |
11484 KB |
Output is correct |
4 |
Correct |
18 ms |
11324 KB |
Output is correct |
5 |
Correct |
17 ms |
11212 KB |
Output is correct |
6 |
Correct |
19 ms |
11468 KB |
Output is correct |
7 |
Correct |
18 ms |
11368 KB |
Output is correct |
8 |
Correct |
22 ms |
11676 KB |
Output is correct |
9 |
Correct |
18 ms |
11420 KB |
Output is correct |
10 |
Correct |
18 ms |
11308 KB |
Output is correct |
11 |
Correct |
17 ms |
11340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
588 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 |
81 ms |
13452 KB |
Output is correct |
2 |
Correct |
134 ms |
24612 KB |
Output is correct |
3 |
Correct |
172 ms |
35484 KB |
Output is correct |
4 |
Correct |
325 ms |
30312 KB |
Output is correct |
5 |
Correct |
74 ms |
9668 KB |
Output is correct |
6 |
Correct |
23 ms |
10160 KB |
Output is correct |
7 |
Correct |
363 ms |
55672 KB |
Output is correct |
8 |
Correct |
11 ms |
1564 KB |
Output is correct |
9 |
Correct |
11 ms |
1552 KB |
Output is correct |
10 |
Correct |
10 ms |
2264 KB |
Output is correct |
11 |
Correct |
9 ms |
1528 KB |
Output is correct |
12 |
Correct |
8 ms |
1612 KB |
Output is correct |
13 |
Correct |
9 ms |
1604 KB |
Output is correct |
14 |
Correct |
9 ms |
1688 KB |
Output is correct |
15 |
Correct |
9 ms |
1628 KB |
Output is correct |
16 |
Correct |
10 ms |
1612 KB |
Output is correct |
17 |
Correct |
10 ms |
1564 KB |
Output is correct |
18 |
Correct |
243 ms |
55708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
22600 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 |
Correct |
9 ms |
1596 KB |
Output is correct |
2 |
Correct |
10 ms |
1612 KB |
Output is correct |
3 |
Correct |
9 ms |
1612 KB |
Output is correct |
4 |
Correct |
9 ms |
1488 KB |
Output is correct |
5 |
Correct |
1 ms |
544 KB |
Output is correct |
6 |
Correct |
5 ms |
1104 KB |
Output is correct |
7 |
Correct |
6 ms |
1172 KB |
Output is correct |
8 |
Correct |
6 ms |
1232 KB |
Output is correct |
9 |
Correct |
6 ms |
1228 KB |
Output is correct |
10 |
Correct |
2 ms |
716 KB |
Output is correct |
11 |
Correct |
5 ms |
1192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
11472 KB |
Output is correct |
2 |
Correct |
18 ms |
11504 KB |
Output is correct |
3 |
Correct |
18 ms |
11484 KB |
Output is correct |
4 |
Correct |
18 ms |
11324 KB |
Output is correct |
5 |
Correct |
17 ms |
11212 KB |
Output is correct |
6 |
Correct |
19 ms |
11468 KB |
Output is correct |
7 |
Correct |
18 ms |
11368 KB |
Output is correct |
8 |
Correct |
22 ms |
11676 KB |
Output is correct |
9 |
Correct |
18 ms |
11420 KB |
Output is correct |
10 |
Correct |
18 ms |
11308 KB |
Output is correct |
11 |
Correct |
17 ms |
11340 KB |
Output is correct |
12 |
Incorrect |
1 ms |
588 KB |
3rd lines differ - on the 2nd token, expected: '1', found: '0' |
13 |
Halted |
0 ms |
0 KB |
- |