Submission #300935

#TimeUsernameProblemLanguageResultExecution timeMemory
300935TMJNMechanical Doll (IOI18_doll)C++17
Compilation error
0 ms0 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; void create_circuit(int M,vector<int>A){ vector<int>X,Y,C; X=Y=vector<int>(400000,0); C=vector<int>(M+1,0); vector<vector<int>>K(M+1); for(int i=1;i<=M;i++){ C[i]=-i*3; X[i*3-1]=-i*3-1; Y[i*3-1]=-i*3-2; X[i*3]=-i*3; Y[i*3]=-i*3; X[i*3+1]=-i*3; Y[i*3+1]=-i*3; } C[0]=A[0]; A.push_back(0); for(int i=0;i<A.size()-1;i++){ K[A[i]].push_back(A[i+1]); } for(int i=1;i<=M;i++){ if(K[i].size()==0)continue; if(K[i].size()==1){ C[i]=K[i][0]; } if(K[i].size()==2){ X[i*3-1]=K[i][0]; Y[i*3-1]=K[i][1]; } if(K[i].size()==3){ X[i*3+1]=K[i][0]; Y[i*3]=K[i][1]; Y[i*3+1]=K[i][2]; } if(K[i].size()==4){ X[i*3]=K[i][0]; X[i*3+1]=K[i][1]; Y[i*3]=K[i][2]; Y[i*3+1]=K[i][3]; } } A.pop_back(); vector<bool>B(400000,false); int p=0; vector<int>T; do{ if(p>=0){ if(p)T.push_back(p); p=M[p]; } else{ if(B[-p-1]){ p=Y[-p-1]; } else{ p=X[-p-1]; } B[-p-1]^=true; } }while(p); assert(A==T); bool f=false; for(int i=0;i<400000;i++){ f|=B[i]; } assert(!f); answer(C,X,Y); }

Compilation message (stderr)

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=0;i<A.size()-1;i++){
      |              ~^~~~~~~~~~~
doll.cpp:53:7: error: invalid types 'int[int]' for array subscript
   53 |    p=M[p];
      |       ^
doll.cpp:62:11: error: no match for 'operator^=' (operand types are 'std::vector<bool>::reference' and 'bool')
   62 |    B[-p-1]^=true;
      |    ~~~~~~~^~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from doll.cpp:2:
/usr/include/c++/10/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator^=(std::byte&, std::byte)'
  168 |   operator^=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/cstddef:168:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
  168 |   operator^=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from doll.cpp:2:
/usr/include/c++/10/bits/ios_base.h:107:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator^=(std::_Ios_Fmtflags&, std::_Ios_Fmtflags)'
  107 |   operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:107:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
  107 |   operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:149:3: note: candidate: 'const std::_Ios_Openmode& std::operator^=(std::_Ios_Openmode&, std::_Ios_Openmode)'
  149 |   operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:149:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
  149 |   operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:189:3: note: candidate: 'const std::_Ios_Iostate& std::operator^=(std::_Ios_Iostate&, std::_Ios_Iostate)'
  189 |   operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:189:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
  189 |   operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:105,
                 from doll.cpp:2:
/usr/include/c++/10/future:170:18: note: candidate: 'std::launch& std::operator^=(std::launch&, std::launch)'
  170 |   inline launch& operator^=(launch& __x, launch __y)
      |                  ^~~~~~~~
/usr/include/c++/10/future:170:37: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::launch&'
  170 |   inline launch& operator^=(launch& __x, launch __y)
      |                             ~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:127,
                 from doll.cpp:2:
/usr/include/c++/10/charconv:688:3: note: candidate: 'constexpr std::chars_format& std::operator^=(std::chars_format&, std::chars_format)'
  688 |   operator^=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/charconv:688:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::chars_format&'
  688 |   operator^=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~