Submission #144521

#TimeUsernameProblemLanguageResultExecution timeMemory
144521arnold518Combo (IOI18_combo)C++14
100 / 100
66 ms624 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2000; int N; char S, P, Q, R; string ans; string guess_sequence(int _N) { int i, j; N=_N; string t; int res; t=string(N, 'A')+string(N, 'B'); res=press(t); if(res>0) { t=string(N, 'A'); res=press(t); if(res>0) S='A', P='B', Q='X', R='Y'; else S='B', P='A', Q='X', R='Y'; } else { t=string(N, 'X'); res=press(t); if(res>0) S='X', P='Y', Q='A', R='B'; else S='Y', P='X', Q='A', R='B'; } ans+=S; if(N==1) return ans; for(i=2; i<N; i++) { t=ans+P+P+ans+P+Q+ans+P+R+ans+Q; res=press(t); if(res==ans.size()+2) ans+=P; else if(res==ans.size()+1) ans+=Q; else ans+=R; } t=ans+P; res=press(t); if(res==N) ans+=P; else { t=ans+Q; res=press(t); if(res==N) ans+=Q; else ans+=R; } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if(res==ans.size()+2) ans+=P;
      |      ~~~^~~~~~~~~~~~~~
combo.cpp:42:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   else if(res==ans.size()+1) ans+=Q;
      |           ~~~^~~~~~~~~~~~~~
combo.cpp:17:9: warning: unused variable 'j' [-Wunused-variable]
   17 |  int i, j;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...