Submission #600549

#TimeUsernameProblemLanguageResultExecution timeMemory
600549BelguteiCombo (IOI18_combo)C++17
100 / 100
56 ms620 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair char a[3000]; string p; string s; void go(char ch) { int cnt = 0; s += ch; if(ch != 'A') { a[cnt] = 'A'; cnt ++; } if(ch != 'B') { a[cnt] = 'B'; cnt ++; } if(ch != 'X') { a[cnt] = 'X'; cnt ++; } if(ch != 'Y') { a[cnt] = 'Y'; cnt ++; } } std::string guess_sequence(int N) { int c = press("AB"); if(c == 2) { s += p; go('A'); } else if(c == 1) { c = press("A"); if(c == 1) go('A'); else go('B'); } else { if(press("X") == 1) go('X'); else go('Y'); } if(s.size() == N) return s; for(int i = s.size() + 1; i < N; i ++) { p = s + a[0] + a[1] + s + a[0] + a[2] + s + a[0] + a[0] + s + a[1]; c = press(p); if(c == s.size() + 2) s += a[0]; else if(c == s.size() + 1) s += a[1]; else s += a[2]; } p = s + a[0]; if(press(p) == N) return p; p = s + a[1]; if(press(p) == N) return p; p = s + a[2]; return p; // std::string p = ""; // for (int i = 0; i < 4 * N; ++i) { // p += 'A'; // } // int coins = press(p); // std::string S = ""; // for (int i = 0; i < N; ++i) { // S += 'A'; // } // return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |   if(s.size() == N) return s;
      |      ~~~~~~~~~^~~~
combo.cpp:42:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if(c == s.size() + 2) s += a[0];
      |        ~~^~~~~~~~~~~~~~~
combo.cpp:43:15: 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(c == s.size() + 1) s += a[1];
      |             ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...