# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
434258 | 2021-06-20T20:04:30 Z | Monchito | 장난감 기차 (IOI17_train) | C++14 | 2000 ms | 1356 KB |
#include "train.h" #include <algorithm> using namespace std; const int MAXN = 5e3; int n, m; int G[MAXN]; bool vis[MAXN]; void DFS(int u, int& ret, vector<int>& r) { vis[u] = true; if(G[u] == u) { ret = (r[u]==1)? 1 : 0; return; } DFS(G[u], ret, r); } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = (int)a.size(); m = (int)u.size(); vector<vector<int>> graph(n); vector<pair<int,int>> edges(m); for(int i=0; i<m; i++) edges[i] = make_pair(u[i], v[i]); sort(edges.begin(), edges.end()); for(int i=0; i<m; i++) graph[edges[i].first].push_back(edges[i].second); for(int i=0; i<n; i++) { if((int)graph[i].size() == 1) { G[i] = graph[i][0]; continue; } if(a[i] == 1) (r[i]==1)? G[i] = graph[i][0] : G[i] = graph[i][1]; else (r[i]==1)? G[i] = graph[i][1] : G[i] = graph[i][0]; } int current; vector<int> ans(n); for(int i=0; i<n; i++) { if(!vis[i]) { DFS(i, current, r); } ans[i] = current; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 844 KB | Output is correct |
2 | Correct | 5 ms | 844 KB | Output is correct |
3 | Correct | 5 ms | 844 KB | Output is correct |
4 | Correct | 5 ms | 808 KB | Output is correct |
5 | Correct | 5 ms | 844 KB | Output is correct |
6 | Correct | 5 ms | 844 KB | Output is correct |
7 | Correct | 5 ms | 844 KB | Output is correct |
8 | Correct | 5 ms | 844 KB | Output is correct |
9 | Correct | 5 ms | 844 KB | Output is correct |
10 | Correct | 5 ms | 844 KB | Output is correct |
11 | Correct | 4 ms | 804 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2072 ms | 204 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2049 ms | 1356 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2076 ms | 1100 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2063 ms | 1316 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 844 KB | Output is correct |
2 | Correct | 5 ms | 844 KB | Output is correct |
3 | Correct | 5 ms | 844 KB | Output is correct |
4 | Correct | 5 ms | 808 KB | Output is correct |
5 | Correct | 5 ms | 844 KB | Output is correct |
6 | Correct | 5 ms | 844 KB | Output is correct |
7 | Correct | 5 ms | 844 KB | Output is correct |
8 | Correct | 5 ms | 844 KB | Output is correct |
9 | Correct | 5 ms | 844 KB | Output is correct |
10 | Correct | 5 ms | 844 KB | Output is correct |
11 | Correct | 4 ms | 804 KB | Output is correct |
12 | Execution timed out | 2072 ms | 204 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |