Submission #939817

#TimeUsernameProblemLanguageResultExecution timeMemory
939817snpmrnhlolCombo (IOI18_combo)C++17
100 / 100
29 ms1864 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; char v[4] = {'A','X','Y','B'}; string guess_sequence(int n){ string s = ""; string ans = ""; for(int i = 0;i < 2*n;i++)s+="A"; for(int i = 0;i < 2*n;i++)s+="X"; int a = press(s); s.clear(); for(int i = 0;i < 2*n;i++)s+="A"; for(int i = 0;i < 2*n;i++)s+="Y"; int b = press(s); if(a && b)ans+="A"; if(!a && b)ans+="Y"; if(a && !b)ans+="X"; if(!a && !b)ans+="B"; if(n == 1)return ans; char c1,c2,c3; for(int i = 0;i < 4;i++){ if(v[i] != ans[0]){ c1 = c2; c2 = c3; c3 = v[i]; } } for(int i = 0;i < n - 2;i++){ string g = ""; g+=ans;g+=c2; g+=ans;g+=c3;g+=c1; g+=ans;g+=c3;g+=c2; g+=ans;g+=c3;g+=c3; while(g.size() < 4*n)g+='A'; int nr = press(g); if(nr == i + 1){ ans+=c1; }else if(nr == i + 2){ ans+=c2; }else{ ans+=c3; } } string g = ""; g+=ans;g+=c1; while(g.size() < 4*n)g+='A'; if(press(g) == n)ans+=c1; else{ string g = ""; g+=ans;g+=c2; while(g.size() < 4*n)g+='A'; if(press(g) == n)ans+=c2; else ans+=c3; } return ans; }

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(g.size() < 4*n)g+='A';
      |               ~~~~~~~~~^~~~~
combo.cpp:46:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |     while(g.size() < 4*n)g+='A';
      |           ~~~~~~~~~^~~~~
combo.cpp:51:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |         while(g.size() < 4*n)g+='A';
      |               ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...