제출 #488880

#제출 시각아이디문제언어결과실행 시간메모리
4888801ne콤보 (IOI18_combo)C++14
0 / 100
0 ms200 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
std::string guess_sequence(int n) {
string a,b,x,y;
a+='A';
b+='B';
x+='X';
y+='Y';
string c;
string s;
if (n==1){
if (press(a)==1){
  c = "BXY";
  s+='A';
}
else if (press(b)==1){
  c = "AXY";
  s+='B';
}
else if (press(x)==1){
  c = "BAY";
  s+='X';
}
else{
  c = "BXA";
  s+='Y';
}
if (n==1){
return s;
}
}
else {
a+=b;
x+=y;
if (press(a)==1){
	a.pop_back();
	if (press(a)==1){
		s+=a;
		c="BXY";
	}
	else{
	  s+=b;
	  c="AXY";
	}
}
else{
 x.pop_back();
 if (press(x)==1){
    s+=x;
    c="ABY";
 }
 else{
    s+=y;
    c="ABX";
 }
}
}
for (int i = 1;i<n-1;++i){
 string q;
 int temp =0;
  q+=s;
  q+=c[0];
  string t;
  t+=s;
  t+=c[1];
  for (auto x:c){
     t+=x;
      q+=t;
      t.pop_back();
  }
  temp = press(q);
  if (temp == s.length()+1){
      s+=c[0];	
  }
  else if(temp==s.length()+2){
  	s+=c[1];
  }
  else s+=c[2];
}
int counts = 0;
for (auto x:c){
	s+=x;
	if (counts==2){
	return s;
	}
	if (press(s)==n){
		return s;
	}
	s.pop_back();
	counts++;
}

  return s;
}

컴파일 시 표준 에러 (stderr) 메시지

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