Submission #428640

#TimeUsernameProblemLanguageResultExecution timeMemory
428640vanicToy Train (IOI17_train)C++14
Compilation error
0 ms0 KiB
#include "train.h" #include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; const int maxn=5005; int n, m; vector < int > ms[maxn]; int charge[maxn]; bool tko[maxn]; bool bio[maxn]; vector < int > sol; vector < int > put; int poc; int dfs(int x){ if(x==poc){ return 1; } if(bio[x]){ return sol[x]; } bio[x]=1; put.push_back(x); for(int i=0; i<ms[x].size(); i++){ sol[x]|=dfs(ms[x][i]); } put.pop_back(); sad[x]=0; } vector < int > who_wins(vector < int > a, vector < int > r, vector < int > u, vector < int > v) { n=a.size(); m=u.size(); for(int i=0; i<n; i++){ tko[i]=a[i]; charge[i]=r[i]; } for(int i=0; i<m; i++){ ms[u[i]].push_back(v[i]); } sol.resize(n, 0); for(int i=0; i<n; i++){ if(charge[i]){ poc=i; dfs(i); } } bool p=1; while(p){ p=0; for(int i=0; i<n; i++){ if(sol[i]){ continue; } for(int j=0; j<ms[i].size(); j++){ if(sol[ms[i][j]]){ sol[i]=1; p=1; break; } } } } return sol; }

Compilation message (stderr)

train.cpp: In function 'int dfs(int)':
train.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i=0; i<ms[x].size(); i++){
      |               ~^~~~~~~~~~~~~
train.cpp:33:2: error: 'sad' was not declared in this scope; did you mean 'std'?
   33 |  sad[x]=0;
      |  ^~~
      |  std
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |    for(int j=0; j<ms[i].size(); j++){
      |                 ~^~~~~~~~~~~~~
train.cpp: In function 'int dfs(int)':
train.cpp:32:14: warning: control reaches end of non-void function [-Wreturn-type]
   32 |  put.pop_back();
      |  ~~~~~~~~~~~~^~