Submission #286524

#TimeUsernameProblemLanguageResultExecution timeMemory
286524stoyan_malinin장난감 기차 (IOI17_train)C++14
Compilation error
0 ms0 KiB
#include "train.h" //#include "grader.cpp" #include <vector> #include <iostream> #include <algorithm> #include <functional> using namespace std; const int MAXN = 5005; int n; vector <int> adj[MAXN]; int owner[MAXN], charging[MAXN]; int guessSubtask(vector <int> a, vector <int> r, vector <int> u, vector <int> v) { bool sub1 = true; for(int i = 0;i<u.size();i++) { if(u[i]!=v[i] && u[i]+1!=v[i]) { sub1 = false; break; } } if(sub1==true) return 1; } vector <int> solve1() { vector <int> res(n, -1); for(int s = 0;s<n;s++) { int x = s; while(true) { int goal = -1; if(owner[x]==1) { if(charging[x]==1) goal = x; else goal = x + 1; bool found = false; for(int y: adj[x]) { if(y==goal) { found =true; break; } } if(found==true) { if(goal==x) { res[s] = true; break; } else { x = x + 1; } } else { res[s] = false; break; } } else { if(charging[x]==1) goal = x + 1; else goal = x; bool found = false; for(int y: adj[x]) { if(y==goal) { found =true; break; } } if(found==true) { if(goal==x) { res[s] = false; break; } else { x = x + 1; } } else { res[x] = true; break; } } } } return res; } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(); for(int i = 0;i<n;i++) { owner[i] = a[i]; charging[i] = r[i]; } for(int i = 0;i<u.size();i++) { adj[ u[i] ].push_back(v[i]); } for(int i = 0;i<n;i++) { sort(adj[i].begin(), adj[i].end()); auto it = unique(adj[i].begin(), adj[i].end()); adj[i].resize(it-adj[i].begin()); } int subtask = guessSubtask(a, r, u, v); if(subtask==1) return solve1(); assert(false); }

Compilation message (stderr)

train.cpp: In function 'int guessSubtask(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0;i<u.size();i++)
      |                   ~^~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:124:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  124 |     for(int i = 0;i<u.size();i++)
      |                   ~^~~~~~~~~
train.cpp:139:5: error: 'assert' was not declared in this scope
  139 |     assert(false);
      |     ^~~~~~
train.cpp:8:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    7 | #include <functional>
  +++ |+#include <cassert>
    8 | 
train.cpp: In function 'int guessSubtask(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:140:1: warning: control reaches end of non-void function [-Wreturn-type]
  140 | }
      | ^