Submission #859766

#TimeUsernameProblemLanguageResultExecution timeMemory
859766dsyzCombo (IOI18_combo)C++17
100 / 100
15 ms1932 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; using ll = long long; #define MAXN (1000005) std::string guess_sequence(int N) { string p = "AB"; ll res = press(p); char firstchar = ' '; if(res >= 1){ p = "A"; res = press(p); if(res >= 1){ firstchar = 'A'; }else{ firstchar = 'B'; } }else{ p = "X"; res = press(p); if(res >= 1){ firstchar = 'X'; }else{ firstchar = 'Y'; } } string ans = ""; ans.push_back(firstchar); vector<char> choices; if(firstchar != 'A') choices.push_back('A'); if(firstchar != 'B') choices.push_back('B'); if(firstchar != 'X') choices.push_back('X'); if(firstchar != 'Y') choices.push_back('Y'); for(ll i = 1;i < N - 1;i++){ p = ans + choices[0] + choices[0]; p += ans + choices[0] + choices[1]; p += ans + choices[0] + choices[2]; p += ans + choices[1]; res = press(p); if(res == ans.size() + 2){ ans.push_back(choices[0]); }else if(res == ans.size() + 1){ ans.push_back(choices[1]); }else if(res == ans.size()){ ans.push_back(choices[2]); } } if(N > 1){ p = ans + choices[0]; res = press(p); if(res == N){ ans.push_back(choices[0]); return ans; } p = ans + choices[1]; res = press(p); if(res == N){ ans.push_back(choices[1]); return ans; } ans.push_back(choices[2]); return ans; } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if(res == ans.size() + 2){
      |      ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:43:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   }else if(res == ans.size() + 1){
      |            ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:45:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   }else if(res == ans.size()){
      |            ~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...