# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
795421 | 2023-07-27T09:24:31 Z | fatemetmhr | Toy Train (IOI17_train) | C++17 | 19 ms | 24916 KB |
// ~ Be Name Khoda ~ // #include "train.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 5e5 + 10; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; int cnt[maxn5], q[maxn5]; vector <int> adj[maxn5], jda[maxn5]; bool mark[maxn5], good[maxn5]; std::vector<int> who_wins(std::vector<int> a, std::vector<int> ch, std::vector<int> u, std::vector<int> v) { int n = a.size(), m = u.size(); int x; for(int i = 0; i < n; i++) if(ch[i]) x = i; for(int i = 0; i < m; i++){ adj[u[i]].pb(v[i]); jda[v[i]].pb(u[i]); cnt[u[i]]++; } int l = 0, r = 0; for(auto u : jda[x]){ if(a[u]){ q[r++] = u; good[u] = true; } else if(cnt[u] > 1) cnt[u]--; else{ q[r++] = u; good[u] = true; } } while(l < r){ int v = q[l++]; for(auto u : jda[v]) if(!good[u]){ if(a[u]){ q[r++] = u; good[u] = true; } else if(cnt[u] > 1) cnt[u]--; else{ q[r++] = u; good[u] = true; } } } vector <int> ret; for(int i = 0; i < n; i++) ret.pb(good[x] && good[i]); return ret; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 24448 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 23796 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 | 15 ms | 24916 KB | Output is correct |
2 | Correct | 15 ms | 24916 KB | Output is correct |
3 | Correct | 16 ms | 24888 KB | Output is correct |
4 | Correct | 17 ms | 24916 KB | Output is correct |
5 | Correct | 18 ms | 24832 KB | Output is correct |
6 | Incorrect | 17 ms | 24836 KB | 3rd lines differ - on the 47th token, expected: '1', found: '0' |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 15 ms | 24700 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 | 16 ms | 24916 KB | Output is correct |
2 | Correct | 16 ms | 24916 KB | Output is correct |
3 | Correct | 16 ms | 24828 KB | Output is correct |
4 | Correct | 18 ms | 24720 KB | Output is correct |
5 | Correct | 14 ms | 23804 KB | Output is correct |
6 | Correct | 16 ms | 24424 KB | Output is correct |
7 | Correct | 15 ms | 24436 KB | Output is correct |
8 | Correct | 19 ms | 24564 KB | Output is correct |
9 | Correct | 16 ms | 24444 KB | Output is correct |
10 | Correct | 12 ms | 24004 KB | Output is correct |
11 | Correct | 15 ms | 24404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 24448 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |