Submission #109621

#TimeUsernameProblemLanguageResultExecution timeMemory
109621polyfishCombo (IOI18_combo)C++14
97 / 100
48 ms568 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; char C[] = {'A', 'B', 'X', 'Y'}; string S; bool find_first_two_char(int x) { int tmp = press(string()+C[x]+C[x+1]+C[x]+C[x+1]); if (tmp==0) return false; if (tmp==1) { if (press(string()+C[x])==1) S += C[x]; else S += C[x+1]; if (press(S+C[(x+2)%4])==2) S += C[(x+2)%4]; else S += C[(x+3)%4]; } else if (tmp==2) { if (press(string()+C[x])==1) S = S + C[x] + C[x+1]; else S = S + C[x+1] + C[x]; } return true; } string special_case() { if (press(string(1, 'A'))) return string(1, 'A'); else if (press(string(1, 'B'))) return string(1, 'B'); else if (press(string(1, 'X'))) return string(1, 'X'); return string(1, 'Y'); } string guess_sequence(int N) { if (N==1) return special_case(); if (!find_first_two_char(0)) find_first_two_char(2); // cerr << S << '\n'; if (N==2) return S; for (int i=0; i<4; ++i) { if (C[i]==S[0]) swap(C[i], C[0]); } for (int i=2; i+1<N; ++i) { // cerr << S << '\n'; // cerr << S+C[1]+C[1]+S+C[1]+C[2]+S+C[1]+C[3]+S+C[2]+C[1] << '\n'; int tmp = press(S+C[1]+C[1]+S+C[1]+C[2]+S+C[1]+C[3]+S+C[2]+C[1]); if (tmp==i-1) { S[i-1] = C[2]; S += C[1]; } if (tmp==i) S += C[3]; if (tmp==i+1) S += C[2]; if (tmp==i+2) S += C[1]; } // cerr << S << '\n'; int tmp = press(S+C[1]); if (tmp<S.size()) { S[N-2] = C[2]; S += C[1]; } else if (tmp==S.size()+1) { S += C[1]; } else if (tmp==S.size()) { if (press(S+C[2])==S.size()+1) S += C[2]; else S += C[3]; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:79:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     if (tmp<S.size()) {
      |         ~~~^~~~~~~~~
combo.cpp:83:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     else if (tmp==S.size()+1) {
      |              ~~~^~~~~~~~~~~~
combo.cpp:86:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |     else if (tmp==S.size()) {
      |              ~~~^~~~~~~~~~
combo.cpp:87:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         if (press(S+C[2])==S.size()+1)
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...