Submission #117684

#TimeUsernameProblemLanguageResultExecution timeMemory
117684PlurmToy Train (IOI17_train)C++14
0 / 100
894 ms1252 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; vector<int> g[5005]; int par[5005]; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { // Subtask 3 for(int i = 0; i < 5005; i++) g[i].clear(); int m = u.size(); for(int i = 0; i < m; i++){ g[u[i]].push_back(v[i]); } int n = a.size(); vector<int> res; for(int i = 0; i < n; i++){ memset(par, -1, sizeof(par)); queue<int> q; q.push(i); par[i] = i; while(!q.empty()){ int cur = q.front(); q.pop(); for(int nxt : g[cur]){ if(par[nxt] == -1){ par[nxt] = cur; q.push(nxt); } } } bool ok = false; for(int j = 0; j < n; j++){ if(r[j]){ if(par[j] != -1) ok = true; } } res.push_back(ok ? 1 : 0); } 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...