Submission #1045640

#TimeUsernameProblemLanguageResultExecution timeMemory
1045640pccToy Train (IOI17_train)C++17
11 / 100
1125 ms4436 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; const int mxn = 5050; vector<int> charge; int N,M; queue<int> q; int owner[mxn]; bitset<mxn> reach[mxn],dist; vector<int> paths[mxn]; bitset<mxn> ban; bitset<mxn> cyc; void BFS(int s = -1){ if(s != -1){ dist.reset(); q.push(s); } while(!q.empty()){ auto now = q.front(); q.pop(); for(auto nxt:paths[now]){ if(!dist[nxt]&&!ban[nxt]){ dist[nxt] = 1; q.push(nxt); } } } return; } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { N = a.size(); for(int i = 0;i<N;i++){ owner[i] = a[i]; if(r[i]){ charge.push_back(i); } } for(int i = 0;i<u.size();i++){ int aa = u[i],bb = v[i]; paths[aa].push_back(bb); } for(int i = 0;i<N;i++){ BFS(i); reach[i] = dist; } for(auto &i:charge)ban[i] = true; for(int i = 0;i<N;i++){ BFS(i); cyc[i] = dist[i]; } /* cerr<<"CYC:";for(int i = 0;i<N;i++)cerr<<cyc[i];cerr<<endl; cerr<<"BAN:";for(int i = 0;i<N;i++)cerr<<ban[i];cerr<<endl; */ vector<int> ans(N,1); for(int i = 0;i<N;i++){ for(int j = 0;j<N;j++){ if(reach[i][j]&&cyc[j])ans[i] = 0; } } 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:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i = 0;i<u.size();i++){
      |                ~^~~~~~~~~
#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...