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 <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include "combo.h"
#define fori(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<n;i++)
#define forib(i,n) for(int i=n-1;i>=0;i--)
#define fornb(i,n) for(int i=n-1;i>0;i--)
#define maxl 10000000000
typedef long long lol;
using namespace std;
typedef vector<int> veci;
typedef pair<lol,lol> point;
lol sum=0;
vector<vector<int>> cons;
char ar[]={'A','B','X','Y'};
string guess_sequence(int n) {
string p = "";
for (int i = 0; i < 2 * n; ++i) {
p.push_back(ar[0]);
}
for (int i = 0; i < 2 * n; ++i) {
p.push_back(ar[1]);
}
string s="";
int coins = press(p);
p = "";
if(coins==0){
for (int i = 0; i < 4 * n; ++i) {
p.push_back(ar[2]);
}
coins = press(p);
p="";
if(coins==0){
s.push_back(ar[3]);
}else{
s.push_back(ar[2]);
}
}else{
for (int i = 0; i < 4 * n; ++i) {
p.push_back(ar[0]);
}
coins = press(p);
p="";
if(coins==0){
s.push_back(ar[1]);
}else{
s.push_back(ar[0]);
}
}
vector<char> arr;
fori(i,4){
if(ar[i]!=s[0]){
arr.push_back(ar[i]);
}
}
for (int i = 0; i < 4 * n; ++i) {
p.push_back(s[0]);
}
while(s.size()<n-1){
fori(i,4){
p[n*i+s.size()-1]=s.back();
}
fori(i,3){
p[n*i+s.size()]=arr[0];
p[n*i+s.size()+1]=arr[i];
}
p[3*n+s.size()]=arr[1];
coins = press(p);
if(coins==s.size()){
s.push_back(arr[2]);
}
if(coins==s.size()+1){
s.push_back(arr[1]);
}
if(coins==s.size()+2){
s.push_back(arr[0]);
}
}
if(s.size()<n){
p="";
for (int i = 0; i < 4 * n; ++i) {
p.push_back(s[0]);
}
fori(i,n-1){
p[i]=s[i];
}
p[n-1]=arr[0];
coins = press(p);
if(coins==n){
s.push_back(arr[0]);
}else{
p[n-1]=arr[1];
coins = press(p);
if(coins==n){
s.push_back(arr[1]);
}else{
s.push_back(arr[2]);
}
}
}
return s;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:66:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
66 | while(s.size()<n-1){
| ~~~~~~~~^~~~
combo.cpp:76:11: 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(coins==s.size()){
| ~~~~~^~~~~~~~~~
combo.cpp:79:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | if(coins==s.size()+1){
| ~~~~~^~~~~~~~~~~~
combo.cpp:82:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | if(coins==s.size()+2){
| ~~~~~^~~~~~~~~~~~
combo.cpp:86:13: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
86 | if(s.size()<n){
| ~~~~~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |