Submission #116533

#TimeUsernameProblemLanguageResultExecution timeMemory
116533SortingCombo (IOI18_combo)C++14
100 / 100
61 ms688 KiB
#include <bits/stdc++.h> using namespace std; int press(string p); string guess_sequence(int n){ string curr = ""; if(press("XY")){ if(press("X")){ curr = "X"; } else{ curr = "Y"; } } else{ if(press("A")){ curr = "A"; } else{ curr = "B"; } } if(n == 1){ return curr; } vector<char> v; v.push_back('A'); v.push_back('B'); v.push_back('X'); v.push_back('Y'); for(char &c: v){ if(c == curr[0]){ swap(c, v.back()); v.pop_back(); break; } } for(int i = 1; i < n - 1; i++){ string q = curr + v[0] + v[0] + curr + v[0] + v[1] + curr + v[0] + v[2] + curr + v[1]; int ans = press(q); if(ans == curr.size()){ curr += v[2]; continue; } if(ans == curr.size() + 1){ curr += v[1]; continue; } curr += v[0]; } if(press(curr + v[0]) == n){ curr += v[0]; return curr; } if(press(curr + v[1]) == n){ curr += v[1]; return curr; } curr += v[2]; return curr; }

Compilation message (stderr)

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