Submission #701029

#TimeUsernameProblemLanguageResultExecution timeMemory
701029BobCompetitiveProgrammingCombo (IOI18_combo)C++14
10 / 100
227 ms568 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; /* int press(string s){ cout << " IN PRESS, ans with string s = " << s << endl; ll ret; cin>>ret; return ret; } */ int press(std::string p); string getRandom(string start, string no, int sz){ while(start.size() < sz){ int r = rand() % 4 + 1; if(r==1 && "A" != no) start += "A"; if(r==2 && "B" != no) start += "B"; if(r==3 && "X" != no) start += "X"; if(r==4 && "Y" != no) start += "Y"; } return start; } string guess_sequence(int N){ string S = "", first; vector<string> buttons{"A", "B", "X", "Y"}; for(auto& button : buttons) if(button=="Y" || press(button)){ first = button, S += button; break; } while(true){ if(S.size() == N) return S; for(auto& button : buttons) { if(button == first) continue; string ra = getRandom(button, first, S.size()); int ret = press(S+ra); if(ret>S.size()) S += ra.substr(0, ret-S.size()); /* if(button=="Y" || (first=="Y" && button =="X") || press(S + button) > S.size()) { S += button; break; } */ } } } /* int main(){ guess_sequence(5); } */

Compilation message (stderr)

combo.cpp: In function 'std::string getRandom(std::string, std::string, int)':
combo.cpp:15:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     while(start.size() < sz){
      |           ~~~~~~~~~~~~~^~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if(S.size() == N)
      |            ~~~~~~~~~^~~~
combo.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             if(ret>S.size())
      |                ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...