Submission #153792

#TimeUsernameProblemLanguageResultExecution timeMemory
153792AlexLuchianovMechanical Doll (IOI18_doll)C++14
Compilation error
0 ms0 KiB
#include "doll.h" #include <iostream> #include <vector> using namespace std; int const nmax = 200000; int left[1 + nmax]; int right[1 + nmax]; int switches = 0; int createpath(vector<int> dest){ if(dest.size() == 1) return dest[0]; vector<int> desteven, destodd; for(int i = 0; i < dest.size(); i += 2) destodd.push_back(dest[i]); for(int i = 1; i < dest.size(); i += 2) desteven.push_back(dest[i]); int central = -(++switches); left[switches] = createpath(destodd); right[switches] = createpath(desteven); return central; } void create_circuit(int M, std::vector<int> A) { int N = A.size(); std::vector<int> C(M + 1); C[0] = 0; for (int i = 1; i <= M; ++i) C[i] = -1; vector<int> dest; for(int i = 0; i < A.size(); i++) dest.push_back(A[i]); dest.push_back(0); createpath(dest); std::vector<int> X(switches), Y(switches); for (int k = 1; k <= switches; ++k) { X[k - 1] = left[k]; Y[k - 1] = right[k]; } answer(C, X, Y); }

Compilation message (stderr)

doll.cpp: In function 'int createpath(std::vector<int>)':
doll.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int i = 0; i < dest.size(); i += 2)
      |                  ~~^~~~~~~~~~~~~
doll.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 = 1; i < dest.size(); i += 2)
      |                  ~~^~~~~~~~~~~~~
doll.cpp:25:3: error: reference to 'left' is ambiguous
   25 |   left[switches] = createpath(destodd);
      |   ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from doll.cpp:2:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
doll.cpp:8:5: note:                 'int left [200001]'
    8 | int left[1 + nmax];
      |     ^~~~
doll.cpp:26:3: error: reference to 'right' is ambiguous
   26 |   right[switches] = createpath(desteven);
      |   ^~~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from doll.cpp:2:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: candidates are: 'std::ios_base& std::right(std::ios_base&)'
 1014 |   right(ios_base& __base)
      |   ^~~~~
doll.cpp:9:5: note:                 'int right [200001]'
    9 | int right[1 + nmax];
      |     ^~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i = 0; i < A.size(); i++)
      |                  ~~^~~~~~~~~~
doll.cpp:48:16: error: reference to 'left' is ambiguous
   48 |     X[k - 1] = left[k];
      |                ^~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from doll.cpp:2:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
doll.cpp:8:5: note:                 'int left [200001]'
    8 | int left[1 + nmax];
      |     ^~~~
doll.cpp:49:16: error: reference to 'right' is ambiguous
   49 |     Y[k - 1] = right[k];
      |                ^~~~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from doll.cpp:2:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: candidates are: 'std::ios_base& std::right(std::ios_base&)'
 1014 |   right(ios_base& __base)
      |   ^~~~~
doll.cpp:9:5: note:                 'int right [200001]'
    9 | int right[1 + nmax];
      |     ^~~~~
doll.cpp:33:7: warning: unused variable 'N' [-Wunused-variable]
   33 |   int N = A.size();
      |       ^