# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
612454 | 2022-07-29T15:23:22 Z | MohamedAliSaidane | Toy Train (IOI17_train) | C++14 | 1114 ms | 1720 KB |
#include <bits/stdc++.h> //#include "train.h" using namespace std; typedef long long ll; typedef double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; #define pb push_back #define popb pop_back #define all(x) (x).begin(),(x).end() #define ff first #define ss second const int nax = 5004; const int MOD = 1e9 + 7; int n, m ; vi adj[nax], rev_adj[nax]; int cnt[nax], sz[nax]; vi who_wins(vi a, vi r, vi u, vi v) { set<int> cur; n = a.size(); m = u.size(); int org; for(int i = 0 ; i < n; i++) { if(r[i]) { cur.insert(i); org = i; } } for(int i= 0; i < m; i ++) { adj[u[i]].pb(v[i]); rev_adj[u[i]].pb(v[i]); } for(int i = 0 ; i < n; i ++ ) sz[i] = (int)(adj[i].size()); for(auto e: cur) { for(auto o: rev_adj[e]) cnt[o]++; } for(int i = 0 ; i < n; i++) { set<int> nw; for(int j= 0; j < n; j ++) { if(cur.count(j) !=0 || nw.count(j) != 0) continue; if(a[j]) { if(cnt[j] > 0) nw.insert(j); } else { if(cnt[j] == sz[j]) nw.insert(j); } } for(auto e: nw) { for(auto o: rev_adj[e]) cnt[o] ++ ; cur.insert(e); } } vi ans(n, 0); if(a[org]) { if(cnt[org] > 0 ) { for(auto e: cur) ans[e] = 1; } } else { if(cnt[org] == sz[org]) for(auto e: cur) ans[e] = 1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1104 ms | 1364 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 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 820 ms | 1720 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 | 1114 ms | 1592 KB | 3rd lines differ - on the 21st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 162 ms | 1564 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 | Incorrect | 1104 ms | 1364 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |