Submission #1061358

#TimeUsernameProblemLanguageResultExecution timeMemory
1061358vjudge1Toy Train (IOI17_train)C++17
0 / 100
4 ms884 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { vector<int> V,v1; int n=a.size(),m=u.size(); bool edg[n]={}; int deg[n]={}; for (int i=0;i<m;i++) deg[u[i]]++; for (int i=0;i<m;i++) { if (u[i]==v[i]) { if (r[u[i]]) { if (a[u[i]] or deg[u[i]]==1) V.push_back(u[i]); } else { if (!a[u[i]] or deg[u[i]]==1) v1.push_back(u[i]); } } else edg[u[i]]=1; } int rc[n]; rc[n-1]=n-1; for (int i=n-2;i>=0;i--) if (edg[i]) rc[i]=rc[i+1]; else rc[i]=i; vector<int> ans(n); for (int i=0;i<n;i++) { int x=lower_bound(V.begin(),V.end(),i)-begin(V); if (x!=V.size()) if (V[x]<=rc[i]) { int y=lower_bound(v1.begin(),v1.end(),V[x])-begin(v1)-1; if (y<0 or v1[y]>V[x]) ans[i]=1; } } return ans; }

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:42:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   if (x!=V.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...