Submission #152522

#TimeUsernameProblemLanguageResultExecution timeMemory
152522ivandasfsCombo (IOI18_combo)C++14
0 / 100
1 ms256 KiB
#include <iostream> #include <algorithm> #include <set> using namespace std; set <char> b; char c[3]; int press(string s); /* string ans = "ABXXY"; int press(string s) { int sol = 0; for (int i=0 ; i<s.size() ; i++) { if (s[i] == ans[0]) { int br = 0; for (int j=0 ; j < ans.size() and i + j < s.size() ; j++) { if (ans[j] == s[i+j]) br++; else break; } sol = max(sol, br); } } return sol; } */ string guess_sequence(int n) { b.insert('A'); b.insert('B'); b.insert('X'); b.insert('Y'); string sol = ""; if (press("AB")) if (press("A")) sol += 'A'; else sol += 'B'; else if (press("C")) sol += 'C'; else sol += 'D'; if (n==1) return sol; b.erase(b.find(sol[0])); int i = 0; for (set<char> :: iterator it = b.begin() ; it!=b.end() ; it++) { c[i++] = *it; } for (int i=1 ; i<n-1 ; i++) { int br = press(sol+c[0] + sol+c[1]+c[0] + sol+c[1]+c[1] + sol+c[1]+c[2]); if (br == sol.size() + 0) sol += c[2]; else if (br == sol.size() + 1) sol += c[0]; else sol += c[1]; } if (press(sol+c[0]) == n) sol += c[0]; else if (press(sol+c[1]) == n) sol += c[1]; else sol += c[2]; return sol; } /* int main() { cout <<guess_sequence(5)<<endl; return 0; } */

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   if (br == sol.size() + 0) sol += c[2];
      |       ~~~^~~~~~~~~~~~~~~~~
combo.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   else if (br == sol.size() + 1) sol += c[0];
      |            ~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...