Submission #417879

#TimeUsernameProblemLanguageResultExecution timeMemory
417879LouayFarahCombo (IOI18_combo)C++14
5 / 100
16 ms200 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; #define pb push_back int press(string p); string guess_sequence(int n) { string res = ""; string temp = "ABXY"; for(int i = 0; i<3; i++) { string tr = ""; tr.pb(temp[i]); if(press(tr)==1) { res.pb(temp[i]); break; } } if(res.length()==0) res.pb('Y'); string used = ""; for(int i = 0; i<4; i++) { if(res[0]==temp[i]) continue; used.pb(temp[i]); } for(int i = 2; i<n; i++) { string s = ""; s = s + res[0] + used[0]; s = s + res[0] + used[1] + used[0]; s = s + res[0] + used[1] + used[1]; s = s + res[0] + used[1] + used[2]; int k = press(s); if(k==(int)res.length()) res.pb(used[2]); if(k==(int)res.length() + 1) res.pb(used[0]); if(k==(int)res.length()+2) res.pb(used[1]); } if(res.length()!=n) { string t = res + used[0]; if(press(t)==n) { res = res + used[0]; return res; } t = res + used[1]; if(press(t)==n) { res = res + used[1]; return res; } res = res + used[2]; return res; } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     if(res.length()!=n)
      |        ~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...