Submission #114097

#TimeUsernameProblemLanguageResultExecution timeMemory
114097Alexa2001Combo (IOI18_combo)C++17
5 / 100
2 ms256 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { int ask1, ask2, ask3, ask4; char a, b, c, d; ask1 = press("AB"); ask2 = (!ask1); ask3 = press("AX"); ask4 = (!ask3); if(ask1 && ask3) a = 'A', b = 'B', c = 'X', d = 'Y'; else if(ask1 && ask4) a = 'B', b = 'A', c = 'X', d = 'Y'; else if(ask2 && ask3) a = 'X', b = 'A', c = 'B', d = 'Y'; else a = 'Y', b = 'A', c = 'B', d = 'X'; string S; S.push_back(a); string s1, s2, s3, s4; s1.push_back(b); s2.push_back(c); s2.push_back(b); s3.push_back(c); s3.push_back(c); s4.push_back(c); s4.push_back(d); string p; while(S.size() + 2 <= N) { p = S + s1 + S + s2 + S + s3 + S + s4; assert(p.size() <= 4 * N); int coins = press(p); if(coins == S.size() + 1) S.push_back(b); else if(coins == S.size() + 2) S.push_back(c); else S.push_back(d); } p = S; p.push_back(b); if(press(p) == N) return p; p = S; p.push_back(c); if(press(p) == N) return p; p = S; p.push_back(d); return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     while(S.size() + 2 <= N)
      |           ~~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:2:
combo.cpp:37:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |         assert(p.size() <= 4 * N);
      |                ~~~~~~~~~^~~~~~~~
combo.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if(coins == S.size() + 1)
      |            ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         else if(coins == S.size() + 2)
      |                 ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...