제출 #299648

#제출 시각아이디문제언어결과실행 시간메모리
299648TMJNCombo (IOI18_combo)C++17
94 / 100
44 ms620 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

const string C[4]={"A","B","X","Y"};

string guess_sequence(int N) {
	string S;
	int t=3;
	for(int i=0;i<3;i++){
		if(press(C[i]))t=i;
	}
	S+=C[t];
	if(N==1)return S;
	for(int i=1;i<N-1;i++){
		string T;
		T+=S+C[(t+1)%4]+C[(t+1)%4]+S+C[(t+1)%4]+C[(t+2)%4]+S+C[(t+1)%4]+C[(t+3)%4]+S+C[(t+2)%4];
		int k=press(T);
		if(k==S.size()){
			S+=C[(t+3)%4];
		}
		else if(k==S.size()+1){
			S+=C[(t+2)%4];
		}
		else{
			S+=C[(t+1)%4];
		}
	}
	for(int i=1;i<=3;i++){
		string T;
		T+=S+C[(t+i)%4];
		if(press(T)==N){
			return T;
		}
	}
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:19:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   if(k==S.size()){
      |      ~^~~~~~~~~~
combo.cpp:22:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   else if(k==S.size()+1){
      |           ~^~~~~~~~~~~~
combo.cpp:8:9: warning: control reaches end of non-void function [-Wreturn-type]
    8 |  string S;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...