# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
413054 | 2021-05-28T07:36:18 Z | 조영욱(#7624) | 장난감 기차 (IOI17_train) | C++14 | 11 ms | 1812 KB |
#include "train.h" #include <bits/stdc++.h> using namespace std; vector<int> adj[5000]; int deg[5000]; int outd[5000]; bool vis[5000]; vector<int> rev[5000]; vector<int> rrev[5000]; 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]); deg[v[i]]++; outd[u[i]]++; } } for(int i=0;i<m;i++){ rev[v[i]].push_back(u[i]); } queue<int> q; for(int i=0;i<n;i++) { if (deg[i]==0) { q.push(i); } } int cnt=0; while (!q.empty()) { int now=q.front(); q.pop(); cnt++; for(int i=0;i<adj[now].size();i++) { int nt=adj[now][i]; deg[nt]--; outd[now]--; if (deg[nt]==0) { q.push(nt); } } } for(int i=0;i<n;i++) { if (outd[i]==0) { q.push(i); } } while (!q.empty()) { int now=q.front(); q.pop(); cnt++; for(int i=0;i<rrev[now].size();i++) { int nt=rrev[now][i]; outd[nt]--; deg[now]--; if (outd[nt]==0) { q.push(nt); } } } for(int i=0;i<n;i++) { if (deg[i]!=0) { 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1124 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 1740 KB | Output is correct |
2 | Correct | 9 ms | 1812 KB | Output is correct |
3 | Correct | 11 ms | 1736 KB | Output is correct |
4 | Incorrect | 10 ms | 1624 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1100 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 1616 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 1124 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |