Submission #1127585

#TimeUsernameProblemLanguageResultExecution timeMemory
1127585Elwino008Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> #include <time.h> using namespace std; #define pb push_back #define all(v) v.begin(), v.end() mt19937 random(time(NULL)); string f(string a, int N, char st){ int n=a.size(); if(n==N-1){ return a; } string q=""; if(st=='A'){ q+=a; q+='B'; q+=a; q+="XB"; q+=a; q+="XX"; q+=a; q+="XY"; int qwe=press(q); if(qwe==n){ a+='Y'; } else if(qwe==n+1){ a+='B'; } else{ a+='X'; } } else if(st=='B'){ q+=a; q+='A'; q+=a; q+="XA"; q+=a; q+="XX"; q+=a; q+="XY"; int qwe=press(q); if(qwe==n){ a+='Y'; } else if(qwe==n+1){ a+='A'; } else{ a+='X'; } } else if(st=='X'){ q+=a; q+='A'; q+=a; q+="BA"; q+=a; q+="BB"; q+=a; q+="BY"; int qwe=press(q); if(qwe==n){ a+='Y'; } else if(qwe==n+1){ a+='A'; } else{ a+='B'; } } else{ q+=a; q+='A'; q+=a; q+="BA"; q+=a; q+="BB"; q+=a; q+="BX"; int qwe=press(q); if(qwe==n){ a+='X'; } else if(qwe==n+1){ a+='A'; } else{ a+='B'; } } return f(a, N, st); } std::string guess_sequence(int N) { vector<string>strt; strt.pb("A"); strt.pb("X"); strt.pb("Y"); strt.pb("B"); sort(all(strt)); shuffle(all(strt), random); char st; string a=""; int ind=0; int q=press(strt[ind]); while(q!=1){ ind++; if(ind==3){ break; } q=press(strt[ind]); } st=strt[ind][0]; a+=st; string ans=f(a, N, st); ind=0; shuffle(all(strt), random); q=press(ans+strt[ind]); while(q!=N){ ind++; if(ind==3){ break; } q=press(ans+strt[ind]); } ans+=strt[ind]; cout<<ans<<endl; return ans; }

Compilation message (stderr)

combo.cpp:10:16: error: 'std::mt19937 random' redeclared as different kind of entity
   10 | mt19937 random(time(NULL));
      |                ^~~~
In file included from /usr/include/c++/11/cstdlib:75,
                 from /usr/include/c++/11/bits/stl_algo.h:59,
                 from /usr/include/c++/11/string:52,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/stdlib.h:402:17: note: previous declaration 'long int random()'
  402 | extern long int random (void) __THROW;
      |                 ^~~~~~
In file included from /usr/include/c++/11/string:52,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/11/bits/stl_algo.h: In instantiation of 'void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >; _UGenerator = long int (&)() noexcept]':
combo.cpp:109:12:   required from here
/usr/include/c++/11/bits/stl_algo.h:3750:9: error: 'std::remove_reference<long int (&)() noexcept>::type' {aka 'long int() noexcept'} is not a class, struct, or union type
 3750 |         __uc_type;
      |         ^~~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:3778:44: error: 'std::remove_reference<long int (&)() noexcept>::type' {aka 'long int() noexcept'} is not a class, struct, or union type
 3778 |           const pair<__uc_type, __uc_type> __pospos =
      |                                            ^~~~~~~~
/usr/include/c++/11/bits/stl_algo.h:3778:44: error: 'std::remove_reference<long int (&)() noexcept>::type' {aka 'long int() noexcept'} is not a class, struct, or union type