Submission #333730

#TimeUsernameProblemLanguageResultExecution timeMemory
333730bigDuckCombo (IOI18_combo)C++14
100 / 100
48 ms576 KiB
#include<bits/stdc++.h> using namespace std; #include "combo.h" #define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define mp make_pair #define pb push_back #define ft first #define sc second #define ll long long #define pii pair<int, int> #define count_bits __builtin_popcount string a="A", b="B", c="X", d="Y"; string guess_1(){ char a='A', b='B', c='X', d='Y'; int l1=0, l2=0, l3=0; string s0="a"; s0[0]=a; l1=press(s0); s0[0]=b; l2=press(s0); s0[0]=c; l3=press(s0); if(l1){ s0[0]=a; return s0; } if(l2){ s0[0]=b; return s0; } if(l3){ s0[0]=c; return s0; } s0[0]=d; return s0; } string guess_3(){ int l=press(a+b); if(l>0){ l=press(a); if(l){ return a; } else{ return b; } } else{ l=press(c); if(l){ return c; } else{ return d; } } //return s0; } string guess_2(){ int l=press(a+b); if(l){ l=press(a+d+a+c); if(l==1){ return a+b; } if(l==2){ l=press(a+d); if(l==2){ return a+d; } else{ return a+c; } } l=press(b+d+b+c); if(l==1){ return b+a; } if(l==2){ l=press(b+d); if(l==2){ return b+d; } else{ return b+c; } } } else{ l=press(c+a+c+b); if(l==1){ return c+d; } if(l==2){ l=press(c+a); if(l==2){ return c+a; } else{ return c+b; } } l=press(d+a+d+b); if(l==1){ return d+c; } if(l==2){ l=press(d+a); if(l==2){ return d+a; } else{ return d+b; } } } } string guess_next(string p, string ft ){ if(ft==a){ int l=(press(p+b+p+c+b+p+c+d+p+c+c))-((int)p.length()); if(l==0){ return p+d; } if(l==1){ return p+b; } if(l==2){ return p+c; } } if(ft==b){ int l=(press(p+a+p+c+a+p+c+d+p+c+c))-((int)p.length()); if(l==0){ return p+d; } if(l==1){ return p+a; } if(l==2){ return p+c; } } if(ft==c){ int l=(press(p+a+p+b+b+p+b+d+p+b+a))-((int)p.length()); if(l==0){ return p+d; } if(l==1){ return p+a; } if(l==2){ return p+b; } } if(ft==d){ int l=(press(p+b+p+c+b+p+c+a+p+c+c))-((int)p.length()); if(l==0){ return p+a; } if(l==1){ return p+b; } if(l==2){ return p+c; } } } string guess_lt(string p, string ft){ if(ft==a){ int l=press(p+b+p+c)-((int)p.length()); if(l==1){ l=press(p+b)-((int)p.length()); if(l==1){ return p+b; } else{ return p+c; } } else{ return p+d; } } if(ft==b){ int l=press(p+d+p+c)-((int)p.length()); if(l==1){ l=press(p+d)-((int)p.length()); if(l==1){ return p+d; } else{ return p+c; } } else{ return p+a; } } if(ft==c){ int l=press(p+b+p+d)-((int)p.length()); if(l==1){ l=press(p+b)-((int)p.length()); if(l==1){ return p+b; } else{ return p+d; } } else{ return p+a; } } if(ft==d){ int l=press(p+b+p+c)-((int)p.length()); if(l==1){ l=press(p+b)-((int)p.length()); if(l==1){ return p+b; } else{ return p+c; } } else{ return p+a; } } } string guess_sequence(int N){ int n=N; if(n==1){ return guess_1(); } if(n==2){ return guess_2(); } string p=guess_3(); while(p.length()<(n-1) ){ string ft="a"; ft[0]=p[0]; p=guess_next(p, ft); } string ft="a"; ft[0]=p[0]; p=guess_lt(p, ft); return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:285:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  285 | while(p.length()<(n-1) ){
      |       ~~~~~~~~~~^~~~~~
combo.cpp: In function 'std::string guess_2()':
combo.cpp:136:1: warning: control reaches end of non-void function [-Wreturn-type]
  136 | }
      | ^
combo.cpp: In function 'std::string guess_next(std::string, std::string)':
combo.cpp:194:1: warning: control reaches end of non-void function [-Wreturn-type]
  194 | }
      | ^
combo.cpp: In function 'std::string guess_lt(std::string, std::string)':
combo.cpp:268:1: warning: control reaches end of non-void function [-Wreturn-type]
  268 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...