Submission #79157

#TimeUsernameProblemLanguageResultExecution timeMemory
79157patcasraresCombo (IOI18_combo)C++14
100 / 100
90 ms660 KiB
#include<fstream> #include<vector> #include "combo.h" #include<iostream> #define pb push_back using namespace std; string guess_sequence(int n) { int r,poz,cnt=-1; char c[4]={'A','B','X','Y'},a[4]; string p,rez; p="AB"; r=press(p); if(r>0) poz=0; else poz=2; p=c[poz]; r=press(p); if(r==0) poz++; rez.pb(c[poz]); for(int i=0;i<4;i++) if(i!=poz) { cnt++; a[cnt]=c[i]; } if(n==1) return rez; for(int i=2;i<n;i++) { string p; for(int j=0;j<rez.size();j++) p.pb(rez[j]); p.pb(a[0]); for(int j=0;j<rez.size();j++) p.pb(rez[j]); p.pb(a[1]); p.pb(a[0]); for(int j=0;j<rez.size();j++) p.pb(rez[j]); p.pb(a[1]); p.pb(a[1]); for(int j=0;j<rez.size();j++) p.pb(rez[j]); p.pb(a[1]); p.pb(a[2]); r=press(p); if(r==i) { rez.pb(a[0]); continue; } if(r==i+1) { rez.pb(a[1]); continue; } rez.pb(a[2]); } string q; for(int j=0;j<rez.size();j++) q.pb(rez[j]); q.pb(a[0]); for(int j=0;j<rez.size();j++) q.pb(rez[j]); q.pb(a[1]); r=press(q); if(r==n) { string p; for(int j=0;j<rez.size();j++) p.pb(rez[j]); p.pb(a[0]); r=press(p); if(r==n) rez.pb(a[0]); else rez.pb(a[1]); } else rez.pb(a[2]); return rez; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int j=0;j<rez.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j=0;j<rez.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int j=0;j<rez.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int j=0;j<rez.size();j++)
      |                     ~^~~~~~~~~~~
combo.cpp:63:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int j=0;j<rez.size();j++)
      |                 ~^~~~~~~~~~~
combo.cpp:66:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for(int j=0;j<rez.size();j++)
      |                 ~^~~~~~~~~~~
combo.cpp:73:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         for(int j=0;j<rez.size();j++)
      |                     ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...