Submission #447549

#TimeUsernameProblemLanguageResultExecution timeMemory
447549MohamedAliSaidaneCombo (IOI18_combo)C++14
94 / 100
48 ms620 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; #define pb push_back #define popb pop_back #define ff first #define ss second const int MOD = 1e9 + 7; const ll INF = 1e18; string guess_sequence(int n) { char but[4] = {'A','B','X','Y'}; string p = ""; string s = ""; int fr = -1; if(press("AB")) { if(press("A")) { s = "A"; fr = 0; } else { s = "B"; fr = 1; } } else if(press("XY")) { if(press("X")) { s = "X"; fr = 2; } else { s = "Y"; fr = 3; } } but[3] = but[fr]; but[fr] = 'Y'; while(s.length() < n -1) { char b = but[0]; char x = but[1]; char y = but[2]; string g = s + b; g += (s+ x + x); g += (s+ x + b); g += (s+ x + y); int tent = press(g); if(tent == s.length() +1) { s += b; } else if(tent == s.length() + 2) { s += x; } else { s += y; } } if(s.length() < n) { for(int j = 0; j < 3; j ++) { string g = s + but[j]; int tent = press(g); if(tent == n) { s += but[j]; break; } } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:50:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |   while(s.length() < n -1)
      |         ~~~~~~~~~~~^~~~~~
combo.cpp:60:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |      if(tent == s.length() +1)
      |         ~~~~~^~~~~~~~~~~~~~~~
combo.cpp:64:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |      else if(tent == s.length() + 2)
      |              ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:73:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |   if(s.length() < n)
      |      ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...