# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413057 | 2021-05-28T07:42:30 Z | 조영욱(#7624) | Toy Train (IOI17_train) | C++14 | 1217 ms | 1988 KB |
#include "train.h" #include <bits/stdc++.h> using namespace std; vector<int> adj[5000]; bool vis[5000]; vector<int> rev[5000]; vector<int> rrev[5000]; bool cycle[5000]; void dfs(int v) { vis[v]=true; for(int i=0;i<adj[v].size();i++) { int nt=adj[v][i]; if (!vis[nt]) { dfs(nt); } } } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int n=a.size(); int m=u.size(); for(int i=0;i<m;i++) { if (r[u[i]]==0&&r[v[i]]==0) { adj[u[i]].push_back(v[i]); rrev[v[i]].push_back(u[i]); } } for(int i=0;i<m;i++){ rev[v[i]].push_back(u[i]); } for(int i=0;i<n;i++) { memset(vis,0,sizeof(vis)); dfs(i); for(int j=0;j<rrev[i].size();j++) { if (vis[rrev[i][j]]) { cycle[i]=true; break; } } } memset(vis,0,sizeof(vis)); queue<int> q; for(int i=0;i<n;i++) { if (cycle[i]) { q.push(i); vis[i]=true; } } while (!q.empty()) { int now=q.front(); q.pop(); for(int i=0;i<rev[now].size();i++) { int nt=rev[now][i]; if (!vis[nt]) { vis[nt]=true; q.push(nt); } } } vector<int> ret(n); for(int i=0;i<n;i++) { if (vis[i]) { ret[i]=0; } else { ret[i]=1; } } return ret; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1100 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 | 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 | 109 ms | 1984 KB | Output is correct |
2 | Correct | 36 ms | 1836 KB | Output is correct |
3 | Correct | 12 ms | 1704 KB | Output is correct |
4 | Incorrect | 531 ms | 1640 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1228 KB | Output is correct |
2 | Correct | 121 ms | 1680 KB | Output is correct |
3 | Correct | 163 ms | 1756 KB | Output is correct |
4 | Correct | 30 ms | 1604 KB | Output is correct |
5 | Correct | 344 ms | 1860 KB | Output is correct |
6 | Correct | 262 ms | 1828 KB | Output is correct |
7 | Correct | 240 ms | 1804 KB | Output is correct |
8 | Correct | 103 ms | 1612 KB | Output is correct |
9 | Correct | 8 ms | 1484 KB | Output is correct |
10 | Correct | 9 ms | 1536 KB | Output is correct |
11 | Correct | 9 ms | 1484 KB | Output is correct |
12 | Correct | 9 ms | 1444 KB | Output is correct |
13 | Correct | 629 ms | 1988 KB | Output is correct |
14 | Correct | 372 ms | 1780 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1217 ms | 1848 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 | 8 ms | 1100 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |