This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include"combo.h"
using namespace std;
// string s;
// int cnt = 0;
// int press(string p) {
// int res = 0;
// for(int i=0; i<p.size(); i++) {
// for(int t=1; t<=s.size() && i+t<=p.size(); t++) {
// if(s.substr(0, t) == p.substr(i, t)) {
// res = max(res, t);
// }
// }
// }
// cnt++;
// return res;
// }
string guess_sequence(int n) {
set<char> possible = {'A','B','X','Y'};
string res;
while(res.size() < n) {
for(char c:possible) {
if(press(res+c) == res.size()+1) {
res += c;
if(res.size() == 1) {
possible.erase(c);
}
break;
}
}
}
return res;
}
// int32_t main(){
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// #define endl '\n'
// s = "X";
// vector<char> possible = {'A','B','Y'};
// while(s.size() < 100) s += possible[rand()%3];
// cout << s << endl;
// cout << guess_sequence(s.size()) << endl;
// cout << cnt << endl;
// return 0;
// }
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
24 | while(res.size() < n) {
| ~~~~~~~~~~~^~~
combo.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | if(press(res+c) == res.size()+1) {
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |