# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
291417 | 2020-09-05T10:21:48 Z | abyyskit | 장난감 기차 (IOI17_train) | C++14 | 2000 ms | 1152 KB |
#include "train.h" #include<bits/stdc++.h> using namespace std; #define FOR(i, x, y) for(int i = x; i < y; ++i) #define pb push_back struct node{ vector<int> e; bool charge = false; bool A = false; bool vis = false; int time = INT_MAX; }; vector<node> g; vector<int> subtask1(){ vector<int> ans(g.size(), 0); for(int i = g.size() - 1; i >= 0; --i){ if (g[i].A){ ans[i] = 0; } else{ ans[i] = 1; } FOR(j, 0, g[i].e.size()){ int nex = g[i].e[j]; // cout << "nex: " << nex << "\n"; if (g[i].A){ if (g[i].charge && nex == i){ ans[i] = 1; break; } if (nex != i){ ans[i] = max(ans[i], ans[i + 1]); } } else{ if (nex == i){ if (!g[i].charge){ ans[i] = 0; break; } } else{ ans[i] = min(ans[i], ans[i + 1]); } } } } return ans; } int s2dfs(int start, int prev){ g[start].vis = true; if (g[start].charge){ prev = g[start].time; } int ans; if (g[start].A){ ans = 0; } else{ ans = 1; } FOR(i, 0, g[start].e.size()){ int nex = g[start].e[i]; if (!g[nex].vis){ g[nex].time = g[start].time + 1; int tmp = s2dfs(nex, prev); if (g[start].A){ ans = max(ans, tmp); } else{ ans = min(ans, tmp); } } else{ if (g[nex].time <= prev){ if (g[start].A){ ans = 1; } } else{ if (!g[start].A){ ans = 0; } } } } g[start].time = INT_MAX; g[start].vis = false; return ans; } vector<int> subtask2(){ vector<int> ans(g.size(), 0); FOR(i, 0, g.size()){ g[i].time = 0; ans[i] = s2dfs(i, -1); g[i].time = INT_MAX; } return ans; } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v){ g.resize(a.size()); FOR(i, 0, u.size()){ g[u[i]].e.pb(v[i]); } // cout << "here\n"; FOR(i, 0, a.size()){ if (a[i] == 1){ g[i].A = true; } if (r[i] == 1){ g[i].charge = true; } } // cout << "here2" << "\n"; return subtask2(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 317 ms | 1144 KB | Output is correct |
2 | Correct | 106 ms | 1008 KB | Output is correct |
3 | Correct | 48 ms | 896 KB | Output is correct |
4 | Correct | 17 ms | 896 KB | Output is correct |
5 | Correct | 9 ms | 800 KB | Output is correct |
6 | Correct | 6 ms | 848 KB | Output is correct |
7 | Correct | 6 ms | 896 KB | Output is correct |
8 | Correct | 6 ms | 896 KB | Output is correct |
9 | Correct | 5 ms | 896 KB | Output is correct |
10 | Correct | 4 ms | 896 KB | Output is correct |
11 | Correct | 4 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 108 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 1 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 256 KB | Output is correct |
9 | Correct | 42 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 24 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 0 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2016 ms | 1152 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2043 ms | 1024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2067 ms | 1152 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 317 ms | 1144 KB | Output is correct |
2 | Correct | 106 ms | 1008 KB | Output is correct |
3 | Correct | 48 ms | 896 KB | Output is correct |
4 | Correct | 17 ms | 896 KB | Output is correct |
5 | Correct | 9 ms | 800 KB | Output is correct |
6 | Correct | 6 ms | 848 KB | Output is correct |
7 | Correct | 6 ms | 896 KB | Output is correct |
8 | Correct | 6 ms | 896 KB | Output is correct |
9 | Correct | 5 ms | 896 KB | Output is correct |
10 | Correct | 4 ms | 896 KB | Output is correct |
11 | Correct | 4 ms | 768 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 256 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 108 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 1 ms | 256 KB | Output is correct |
18 | Correct | 1 ms | 256 KB | Output is correct |
19 | Correct | 3 ms | 256 KB | Output is correct |
20 | Correct | 42 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 256 KB | Output is correct |
22 | Correct | 24 ms | 256 KB | Output is correct |
23 | Correct | 1 ms | 256 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
26 | Correct | 1 ms | 256 KB | Output is correct |
27 | Correct | 0 ms | 256 KB | Output is correct |
28 | Correct | 0 ms | 256 KB | Output is correct |
29 | Correct | 1 ms | 256 KB | Output is correct |
30 | Correct | 1 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Execution timed out | 2016 ms | 1152 KB | Time limit exceeded |
33 | Halted | 0 ms | 0 KB | - |