Submission #314116

#TimeUsernameProblemLanguageResultExecution timeMemory
314116Lemur95Combo (IOI18_combo)C++17
100 / 100
59 ms512 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define x first #define y second #define ld long double #define ll long long using namespace std; int n; string s; int press(string p); /*int press(string p) { int ans = 0; for(int i = 0; i < p.size(); i++) { for(int j = i; j < i + s.size() && j < p.size(); j++) { if(p[j] == s[j - i]) ans = max(ans, j - i + 1); else break; } } return ans; }*/ string guess_sequence(int n) { string s, t; if(press("AB")) { if(press("A")) { s += 'A'; t = "BXY"; } else { s += 'B'; t = "AXY"; } } else { if(press("X")) { s += 'X'; t = "ABY"; } else { s += 'Y'; t = "ABX"; } } if(n == 1) return s; for(int i = 1; i < n - 1; i++) { int ans = press(s + t[0] + s + t[1] + t[0] + s + t[1] + t[1] + s + t[1] + t[2]) - s.size(); if(ans == 0) s += t[2]; else if(ans == 1) s += t[0]; else s += t[1]; } if(press(s + t[0] + s + t[1]) > s.size()) { if(press(s + t[0]) > s.size()) s += t[0]; else s += t[1]; } else s += t[2]; return s; } /*int main() { ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> s; string ans = guess_sequence(n); if(ans == s) cout << "Accepted!"; else cout << "Wrong answer, output = " << ans; return 0; }*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:58:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   if(press(s + t[0] + s + t[1]) > s.size()) {
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:59:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     if(press(s + t[0]) > s.size())
      |        ~~~~~~~~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...