# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
987185 | 2024-05-22T09:06:13 Z | AdamGS | Toy Train (IOI17_train) | C++17 | 869 ms | 1708 KB |
#include "train.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=5e3+7; vector<int>V[LIM], S[LIM]; int deg[LIM]; vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) { int n=a.size(), m=u.size(); vector<int>ans(n); rep(i, m) { V[u[i]].pb(v[i]); S[v[i]].pb(u[i]); } rep(i, n) { rep(j, n) { ans[j]=1; if(r[j]) deg[j]=0; else if(a[j]) deg[j]=V[j].size(); else deg[j]=1; } queue<int>q; rep(j, n) if(deg[j]==0) q.push(j); while(!q.empty()) { int p=q.front(); q.pop(); ans[p]=0; for(auto j : S[p]) { --deg[j]; if(deg[j]==0) q.push(j); } } rep(j, n) if(r[j]) { int sum=0; for(auto l : V[j]) sum+=ans[l]; if(a[j] && sum==V[j].size() || !a[j] && sum) r[j]=0; } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 458 ms | 1116 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 | 604 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 | 101 ms | 1624 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 | 683 ms | 1524 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 | 869 ms | 1708 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 | 458 ms | 1116 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |