Submission #775977

#TimeUsernameProblemLanguageResultExecution timeMemory
775977AmylopectinToy Train (IOI17_train)C++14
0 / 100
5 ms1228 KiB
#include "train.h" #include <vector> #include <algorithm> #include <stdio.h> using namespace std; // const int mxn = 20; const int mxn = 1e4 + 10; vector<int> pat[mxn] = {},ans; int batt[mxn] = {},who[mxn] = {},n,u[mxn] = {},res[mxn] = {},nba[mxn] = {}; int re(int cn,int cnba) { int i,j,fn,of = 0; u[cn] = 1; nba[cn] = cnba; cnba += batt[cn]; if(who[cn] == 1) { for(i=0; i<pat[cn].size(); i++) { fn = pat[cn][i]; // if(u[fn] == 2) // { // if(res[fn] == 1) // { // of = 1; // break; // } // } // else if(u[fn] == 1) if(u[fn] == 1) { if(nba[fn] < cnba) { of = 1; break; } } else { re(fn,cnba); if(res[fn] == 1) { of = 1; break; } } } if(of == 0) { res[cn] = 0; } else { res[cn] = 1; } } else { for(i=0; i<pat[cn].size(); i++) { fn = pat[cn][i]; // if(u[fn] == 2) // { // if(res[fn] == 0) // { // of = 1; // break; // } // } // else if(u[fn] == 1) if(u[fn] == 1) { if(nba[fn] == cnba) { of = 1; break; } } else { re(fn,cnba); if(res[fn] == 0) { of = 1; break; } } } if(of == 0) { res[cn] = 1; } else { res[cn] = 0; } } u[cn] = 2; return 0; } std::vector<int> who_wins(std::vector<int> aa, std::vector<int> rr , std::vector<int> uu, std::vector<int> vv) { int i,j,m = uu.size(),cn,cm,fn,fm,ccou = 0; n = aa.size(); for(i=0; i<n; i++) { who[i] = aa[i]; batt[i] = rr[i]; ccou += batt[i]; } for(i=0 ;i<m; i++) { pat[uu[i]].push_back(vv[i]); } // for(i=0; i<n; i++) // { // if(batt[i] == 1) // { // re(i,0); // } // } // for(i=0; i<n; i++) // { // if(res[i] == 0 && u[i] == 2) // { // u[i] = 0; // } // } // for(i=0; i<n; i++) // { // for(j=0; j<n; j++) // { // u[j] = 0; // } // // if(u[i] == 0) // // { // re(i,0); // ans.push_back(res[i]); // // } // } if(ccou > 0) { for(i=0; i<n; i++) { ans.push_back(1); } } else { for(i=0; i<n; i++) { ans.push_back(0); } } // for(i=0; i<n; i++) // { // ans.push_back(res[i]); // } return ans; // std::vector<int> res(a.size()); // for(int i = 0; i < (int)res.size(); i++) // res[i] = i % 2; // return res; }

Compilation message (stderr)

train.cpp: In function 'int re(int, int)':
train.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(i=0; i<pat[cn].size(); i++)
      |            ~^~~~~~~~~~~~~~~
train.cpp:61:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   for(i=0; i<pat[cn].size(); i++)
      |            ~^~~~~~~~~~~~~~~
train.cpp:14:8: warning: unused variable 'j' [-Wunused-variable]
   14 |  int i,j,fn,of = 0;
      |        ^
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:106:8: warning: unused variable 'j' [-Wunused-variable]
  106 |  int i,j,m = uu.size(),cn,cm,fn,fm,ccou = 0;
      |        ^
train.cpp:106:24: warning: unused variable 'cn' [-Wunused-variable]
  106 |  int i,j,m = uu.size(),cn,cm,fn,fm,ccou = 0;
      |                        ^~
train.cpp:106:27: warning: unused variable 'cm' [-Wunused-variable]
  106 |  int i,j,m = uu.size(),cn,cm,fn,fm,ccou = 0;
      |                           ^~
train.cpp:106:30: warning: unused variable 'fn' [-Wunused-variable]
  106 |  int i,j,m = uu.size(),cn,cm,fn,fm,ccou = 0;
      |                              ^~
train.cpp:106:33: warning: unused variable 'fm' [-Wunused-variable]
  106 |  int i,j,m = uu.size(),cn,cm,fn,fm,ccou = 0;
      |                                 ^~
#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...