# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
767212 | 2023-06-26T13:59:52 Z | APROHACK | Toy Train (IOI17_train) | C++14 | 2000 ms | 1428 KB |
#include "train.h" #include<bits/stdc++.h> #define pb push_back #define ll long long #define ff first #define ss second using namespace std; int n; vector<bool>owner, charging; vector<int>adj[5001]; bool vis[5001]; vector<int>nodos; bool dfs(int node){ ////cout << "were " << node << endl; bool isA = owner[node]; bool isCharging = charging[node]; vis[node] = true; nodos.pb(node); for(int i = 0 ; i < adj[node].size() ; i ++){ if(!vis[adj[node][i]]){ if(dfs(adj[node][i]) == isA){ nodos.pop_back(); vis[node] = false; return isA; } }else{ bool hayC = false; for(int j = nodos.size()-1 ; j>= 0 ; j --){ if(charging[nodos[j]])hayC = true; if(nodos[j] == adj[node][i])break; } if((hayC && isA) or (!hayC && !isA)){ nodos.pop_back(); vis[node] = false; } if(hayC && isA)return true; else if(!hayC && !isA)return false; } } nodos.pop_back(); vis[node] = false; return !isA; } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { n = a.size(); vector<int> res; memset(vis, false, sizeof vis); for(int i = 0 ; i < n ; i ++){ owner.pb(a[i]); res.pb(0); charging.pb(r[i]); } for(int i = 0 ; i < u.size() ; i ++){ adj[u[i]].pb(v[i]); } for(int i = 0 ; i < n ; i ++){ if(dfs(i)){ res[i] = 1; }else res[i] = 0; } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 844 KB | Output is correct |
2 | Correct | 4 ms | 868 KB | Output is correct |
3 | Correct | 4 ms | 852 KB | Output is correct |
4 | Correct | 3 ms | 852 KB | Output is correct |
5 | Correct | 4 ms | 848 KB | Output is correct |
6 | Correct | 3 ms | 852 KB | Output is correct |
7 | Correct | 3 ms | 812 KB | Output is correct |
8 | Correct | 3 ms | 864 KB | Output is correct |
9 | Correct | 3 ms | 852 KB | Output is correct |
10 | Correct | 3 ms | 852 KB | Output is correct |
11 | Correct | 3 ms | 816 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 424 KB | Output is correct |
3 | Correct | 1 ms | 424 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 420 KB | Output is correct |
6 | Correct | 1 ms | 508 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 420 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2062 ms | 1236 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2047 ms | 1236 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2097 ms | 1428 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 844 KB | Output is correct |
2 | Correct | 4 ms | 868 KB | Output is correct |
3 | Correct | 4 ms | 852 KB | Output is correct |
4 | Correct | 3 ms | 852 KB | Output is correct |
5 | Correct | 4 ms | 848 KB | Output is correct |
6 | Correct | 3 ms | 852 KB | Output is correct |
7 | Correct | 3 ms | 812 KB | Output is correct |
8 | Correct | 3 ms | 864 KB | Output is correct |
9 | Correct | 3 ms | 852 KB | Output is correct |
10 | Correct | 3 ms | 852 KB | Output is correct |
11 | Correct | 3 ms | 816 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 424 KB | Output is correct |
14 | Correct | 1 ms | 424 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 420 KB | Output is correct |
17 | Correct | 1 ms | 508 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 420 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Execution timed out | 2062 ms | 1236 KB | Time limit exceeded |
33 | Halted | 0 ms | 0 KB | - |