Submission #282330

#TimeUsernameProblemLanguageResultExecution timeMemory
282330Noam13Toy Train (IOI17_train)C++14
28 / 100
288 ms1664 KiB
#include <bits/stdc++.h> #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define vvb vector<vb> #define ii pair<int, int> #define x first #define y second #define vii vector<ii> #define pb push_back #define all(x) x.begin(), x.end() #define loop(i,s,e) for(int i=s;i<e;++i) #define loopr(i,s,e) for(int i=e-1;i>=s;--i) #define chkmin(a,b) a = min(a,b) #define chkmax(a,b) a = max(a,b) using namespace std; const int INF = 1e9; int n; vvi g, ag; vi a,r; vi res; vb f(vb& s, int who){ // a = 1, b = 0 vb check(n,0); vi deg(n); loop(i,0,n) deg[i] = g[i].size(); queue<int> q; loop(i,0,n) if(s[i]) q.push(i), check[i]=1, deg[i]=0; while(q.size()){ int cur = q.front(); q.pop(); for(auto nei:ag[cur]){ if (res[nei]!=-1) continue; if (a[nei]==who){ if (!check[nei]){ check[nei] = 1; q.push(nei); } } else{ if (--deg[nei]==0){ check[nei] = 1; q.push(nei); } } } } return check; } vi who_wins(vi aa, vi rr, vi u, vi v) { a = aa, r = rr; n = a.size(); g.resize(n); ag.resize(n); loop(i,0,u.size()){ int a = u[i], b = v[i]; g[a].pb(b); ag[b].pb(a); } res.resize(n,-1); while(1){ vb b(n); loop(i,0,n) if(r[i] && res[i]==-1){ b[i] = 1; } b = f(b, 1); int cnt = 0, sz=0, cnt2=0; loop(i,0,n) if(res[i]==-1) cnt2+=b[i], b[i]=!b[i], sz++; if (cnt2==sz || sz==0){ loop(i,0,n) if(res[i]==-1) res[i]=1; break; } b = f(b,0); loop(i,0,n) if(b[i]) cnt++; if (cnt==0){ loop(i,0,n) if(res[i]==-1) res[i]=1; break; } loop(i,0,n) if(b[i]) res[i]=0; } return res; } /* clear g++ c.cpp grader.cpp -o c ; ./c 6 7 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 2 2 3 3 1 4 5 5 5 4 1 */

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:12:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 | #define loop(i,s,e) for(int i=s;i<e;++i)
......
   56 |     loop(i,0,u.size()){
      |          ~~~~~~~~~~~~             
train.cpp:56:5: note: in expansion of macro 'loop'
   56 |     loop(i,0,u.size()){
      |     ^~~~
#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...