Submission #633504

#TimeUsernameProblemLanguageResultExecution timeMemory
633504anjamilicevicCombo (IOI18_combo)C++14
100 / 100
40 ms540 KiB
#include "combo.h" #include <bits/stdc++.h> #define IOS {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } #define pb push_back using namespace std; vector<char> v={'A', 'B', 'X', 'Y'}, w; string guess_sequence(int n) { string s=""; char x; string p="AB"; if(press(p)) { x='B'; if(press("A"))x='A'; } else { x='Y'; if(press("X"))x='X'; } s+=x; for(auto u:v) { if(u!=x)w.pb(u); } while(s.size() < n-1) { string q=s+w[0]+s+w[1]+w[0]+s+w[1]+w[1]+s+w[1]+w[2]; int cnt=press(q); int vel=s.size(); if(cnt == vel+1)s+=w[0]; else if(cnt == vel+2)s+=w[1]; else if(cnt == vel)s+=w[2]; } if(n>1) { char c=w[2]; for(int i=0; i<2; i++) { string k=s+w[i]; if(press(k) == n) { c=w[i]; break; } } s+=c; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     while(s.size() < n-1)
      |           ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...