Submission #426991

#TimeUsernameProblemLanguageResultExecution timeMemory
426991someoneToy Train (IOI17_train)C++14
0 / 100
1406 ms1184 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; const int N = 1e4 + 42, INF = 1e9; bool ch[N]; int n, m, val[N][2]; vector<int> adj[N]; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(); m = u.size(); for(int i = 0; i < m; i++) adj[v[i]].push_back(u[i]); for(int i = 0; i < 2*n; i++) { for(int j = 0; j < n; j++) if(r[j] == 1) val[j][i % 2] = max(n, val[j][i % 2]); for(int j = 0; j < n; j++) if(a[0] == 1) val[j][1 - (i % 2)] = 0; else val[j][1 - (i % 2)] = INF; for(int j = 0; j < n; j++) { for(int k : adj[j]) { if(a[0] == 1) val[k][1 - (i % 2)] = max(val[k][1 - (i % 2)], val[j][i % 2] - 1); else val[k][1 - (i % 2)] = min(val[k][1 - (i % 2)], val[j][i % 2] - 1); } } } int i = 3*n; if(r[i] == 1) val[i][i % 2] += n; for(int j = 0; j < n; j++) if(a[0] == 1) val[j][1 - (i % 2)] = 0; else val[j][1 - (i % 2)] = INF; for(int j = 0; j < n; j++) for(int k : adj[j]) if(a[0] == 1) { if(val[k][1 - (i % 2)] != max(val[k][1 - (i % 2)], val[j][i % 2] - 1)) { ch[k] = true; } } else { if(val[k][1 - (i % 2)] != min(val[k][1 - (i % 2)], val[j][i % 2] - 1)) { ch[k] = true; } } vector<int> res(n); for(int i = 0; i < n; i++) if(ch[i]) res[i] = 1; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...