Submission #891217

#TimeUsernameProblemLanguageResultExecution timeMemory
891217vjudge1Combo (IOI18_combo)C++17
100 / 100
12 ms1708 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; string guess_sequence(int N) { char lit[] = {'A', 'B', 'X', 'Y'}; int prima = 0; if(press("AB")) { if(press("A")) prima = 0; else prima = 1; } else { if(press("X")) prima = 2; else prima = 3; } string cur; cur += lit[prima]; vector<char> dif; for(int j = 0; j < 4; ++j) if(j != prima) dif.push_back(lit[j]); if(N == 1) return cur; for(int i = 1; i + 1 < N; ++i) { string s = cur + dif[0] + cur + dif[1] + dif[0] + cur + dif[1] + dif[1] + cur + dif[1] + dif[2]; //cout << "Dau query la " << s << " si obtin "; int v = press(s); // cout << v << "\n"; if(v == cur.size()) { cur += dif[2]; } else if( v == cur.size() + 1 ) { cur += dif[0]; } else cur += dif[1]; // cout << cur << "\n"; } if(press(cur + dif[0]) == N) { cur += dif[0]; } else if(press(cur + dif[1]) == N) { cur += dif[1]; } else cur += dif[2]; return cur; }

Compilation message (stderr)

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