Submission #794232

#TimeUsernameProblemLanguageResultExecution timeMemory
794232alvingogoToy Train (IOI17_train)C++14
11 / 100
1000 ms99300 KiB
#include "train.h" #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define AquA cin.tie(0);ios_base::sync_with_stdio(0); #define fs first #define sc second #define p_q priority_queue using namespace std; typedef long long ll; const ll inf=1e9; vector<vector<int> > e; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int n=a.size(),m=u.size(); vector<int> ans(n); e.resize(n); for(int i=0;i<m;i++){ e[u[i]].push_back(v[i]); } vector<vector<int> > ab(n,vector<int>(n)); for(int i=0;i<n;i++){ queue<int> q; q.push(i); while(q.size()){ auto h=q.front(); q.pop(); for(auto y:e[h]){ if(!ab[i][y]){ ab[i][y]=1; q.push(y); } } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(ab[i][j] && ab[j][j] && r[j]==1){ ans[i]=1; } } } return ans; }
#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...