# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
413062 | 2021-05-28T07:49:11 Z | 조영욱(#7624) | Toy Train (IOI17_train) | C++14 | 841 ms | 1824 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++){ adj[u[i]].push_back(v[i]); rev[v[i]].push_back(u[i]); } for(int i=0;i<n;i++) { if (r[i]==0) { continue; } memset(vis,0,sizeof(vis)); dfs(i); for(int j=0;j<rev[i].size();j++) { if (vis[rev[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]=1; } else { ret[i]=0; } } return ret; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 151 ms | 1388 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 | 588 KB | 3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 1612 KB | Output is correct |
2 | Correct | 34 ms | 1732 KB | Output is correct |
3 | Correct | 62 ms | 1752 KB | Output is correct |
4 | Correct | 357 ms | 1732 KB | Output is correct |
5 | Correct | 47 ms | 1740 KB | Output is correct |
6 | Correct | 84 ms | 1676 KB | Output is correct |
7 | Correct | 246 ms | 1612 KB | Output is correct |
8 | Correct | 12 ms | 1612 KB | Output is correct |
9 | Correct | 11 ms | 1564 KB | Output is correct |
10 | Correct | 11 ms | 1612 KB | Output is correct |
11 | Correct | 9 ms | 1612 KB | Output is correct |
12 | Correct | 8 ms | 1484 KB | Output is correct |
13 | Correct | 10 ms | 1800 KB | Output is correct |
14 | Correct | 10 ms | 1816 KB | Output is correct |
15 | Correct | 10 ms | 1824 KB | Output is correct |
16 | Correct | 10 ms | 1740 KB | Output is correct |
17 | Correct | 10 ms | 1804 KB | Output is correct |
18 | Correct | 183 ms | 1428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 841 ms | 1412 KB | 3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 1612 KB | 3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 151 ms | 1388 KB | 3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |