Submission #493036

#TimeUsernameProblemLanguageResultExecution timeMemory
493036buidangnguyen05Combo (IOI18_combo)C++14
100 / 100
38 ms556 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { string s=""; if(press("AB")) s.push_back((press("A") ? 'A' : 'B')); else s.push_back((press("X")) ? 'X' : 'Y'); if(n==1) return s; vector<char> ord; if(s[0]!='A') ord.push_back('A'); if(s[0]!='B') ord.push_back('B'); if(s[0]!='X') ord.push_back('X'); if(s[0]!='Y') ord.push_back('Y'); for(int i=1; i<n-1; ++i) { int len=press(s+ord[0] + s+ord[1]+ord[0] + s+ord[1]+ord[1] + s+ord[1]+ord[2]); if(len==s.size()) s.push_back(ord[2]); else if(len==s.size()+1) s.push_back(ord[0]); else s.push_back(ord[1]); } if(press(s+ord[0] + s+ord[1]) == s.size()) s.push_back(ord[2]); else s.push_back((press(s+ord[0])==n ? ord[0] : ord[1])); return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if(len==s.size()) s.push_back(ord[2]);
      |            ~~~^~~~~~~~~~
combo.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         else if(len==s.size()+1) s.push_back(ord[0]);
      |                 ~~~^~~~~~~~~~~~
combo.cpp:25:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     if(press(s+ord[0] + s+ord[1]) == s.size()) s.push_back(ord[2]);
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...