Submission #612615

#TimeUsernameProblemLanguageResultExecution timeMemory
612615MohamedAliSaidaneToy Train (IOI17_train)C++14
12 / 100
2076 ms1764 KiB
#include <bits/stdc++.h> //#include "train.h" using namespace std; typedef long long ll; typedef double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; #define pb push_back #define popb pop_back #define all(x) (x).begin(),(x).end() #define ff first #define ss second const int nax = 5004; const int MOD = 1e9 + 7; int n, m ; vi adj[nax], rev_adj[nax]; int cnt[nax], sz[nax]; vi who_wins(vi a, vi r, vi u, vi v) { n = a.size(); m = u.size(); for(int i= 0; i < m; i ++) { adj[u[i]].pb(v[i]); rev_adj[v[i]].pb(u[i]); } for(int i = 0 ; i < n; i ++ ) sz[i] = (int)(adj[i].size()); vi ans(n, 0); for(int org = 0; org < n; org ++) { if(!r[org]) continue; set<int> cur; memset(cnt,0,sizeof(cnt)); cur.insert(org); for(auto o: rev_adj[org]) cnt[o]++; for(int i = 0 ; i < n; i++) { set<int> nw; for(int j= 0; j < n; j ++) { if(cur.count(j) !=0 || nw.count(j) != 0) continue; if(a[j]) { if(cnt[j] > 0) nw.insert(j); } else { if(cnt[j] == sz[j]) nw.insert(j); } } for(auto e: nw) { for(auto o: rev_adj[e]) cnt[o] ++ ; cur.insert(e); } } if(a[org]) { if(cnt[org] > 0 ) { for(auto e: cur) ans[e] = 1; } } else { if(cnt[org] == sz[org]) for(auto e: cur) ans[e] = 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...