Submission #237468

#TimeUsernameProblemLanguageResultExecution timeMemory
237468A02Combo (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include "combo.h" #include<iostream> #include<vector> using namespace std; string guess_sequence(int N) { string p = "AB"; int coins = press(p); string S = ""; char first = 'A'; if (coins > 0){ coins = press("A"); if (coins > 0){ S = "A"; first = 'A'; } else { first = 'B'; S = "B"; } } else { coins = press("X"); if (coins > 0){ S = "X"; first = 'X'; } else { first = 'Y'; S = "Y"; } } vector<char> not_first; vector<char> possible; possible.push_back('A'); possible.push_back('B'); possible.push_back('X'); possible.push_back('Y'); for (int i = 0; i < 4; i++){ if (possible[i] != first){ not_first.push_back(possible[i]); } } while (S.size() < N){ cout << S << ' ' << N << endl; int t = S.size(); if (S.size() == N - 1){ coins = press(S + not_first[0] + S + not_first[1]); if (coins == t){ S += not_first[2]; break; } coins = press(S + not_first[0]); if (coins == t + 1){ S += not_first[0]; break; } S += not_first[1]; break; } string to_test = S + not_first[0] + not_first[0] + S + not_first[0] + not_first[1] + S + not_first[0] + not_first[2] + S + not_first[1]; coins = press(to_test); if (coins == t + 2){ S = S + not_first[0]; } if (coins == t + 1){ S = S + not_first[1]; } if (coins == t){ S = S + not_first[2]; } } return S; }

Compilation message (stderr)

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