Submission #143563

#TimeUsernameProblemLanguageResultExecution timeMemory
143563mat_vCombo (IOI18_combo)C++14
100 / 100
54 ms680 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string a = "AB"; string b = "B"; string x = "X"; string tren; int prvi = press(a); if(prvi){ a.clear(); a += 'A'; prvi = press(a); if(prvi)tren = 'A'; else tren = 'B'; } else{ prvi = press(x); if(prvi)tren = 'X'; else tren = 'Y'; } string d,t,c; if(tren == "A"){ d = "X"; t = "Y"; c = "B"; } else if(tren == "B"){ d = 'X'; t = 'Y'; c = 'A'; } else if(tren == "X"){ d = 'A'; t = 'Y'; c = 'B'; } else if(tren == "Y"){ d = 'X'; t = 'A'; c = 'B'; } for(int i=1; i<N; i++){ if(i == N-1){ string frs = tren; frs += d; string frs2 = tren; frs2 += t; int sta = press(frs); int sta2 = press(frs2); if(sta > sta2)tren += d; else if(sta2 > sta)tren += t; else tren += c; continue; } string frs = tren; frs += d; string sek1 = tren,sek2 = tren,sek3 = tren; string pom1 = t; pom1 += t; string pom2 = t; pom2 += d; string pom3 = t; pom3 += c; sek1 += pom1; sek2 += pom2; sek3 += pom3; frs += sek1; frs += sek2; frs += sek3; int sta = press(frs); if(sta == tren.size())tren += c; else if(sta == tren.size() + 1)tren += d; else tren += t; } //cout << tren << endl; return tren; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:76:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         if(sta == tren.size())tren += c;
      |            ~~~~^~~~~~~~~~~~~~
combo.cpp:77:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |         else if(sta == tren.size() + 1)tren += d;
      |                 ~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...