Submission #477455

#TimeUsernameProblemLanguageResultExecution timeMemory
477455SlavicGCombo (IOI18_combo)C++17
100 / 100
34 ms660 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; #define ll long long #define forn(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define sz(a) (int)a.size() string guess_sequence(int n){ string cur = ""; vector<char> c; c.pb('X'); c.pb('Y'); c.pb('A'); c.pb('B'); char first = 'f'; if(press("XY")){ if(press("X"))first = 'X'; else first = 'Y'; }else{ if(press("A"))first = 'A'; else first = 'B'; } c.erase(find(all(c), first)); assert(sz(c) == 3); cur += first; for(int i = 1;i < n - 1;++i){ string qr = cur; qr += c[0]; qr += c[0]; qr += cur; qr += c[0]; qr += c[1]; qr += cur; qr += c[0]; qr += c[2]; qr += cur; qr += c[1]; int x = press(qr); if(x == 2 + cur.size()){ cur += c[0]; }else if(x == 1 + cur.size()){ cur += c[1]; }else{ cur += c[2]; } } if(sz(cur) < n){ if(press(cur + c[0]) == n)cur += c[0]; else if(press(cur + c[1]) == n)cur += c[1]; else cur += c[2]; } assert(sz(cur) == n); return cur; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:50:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         if(x == 2 + cur.size()){
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         }else if(x == 1 + cur.size()){
      |                  ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...