제출 #209465

#제출 시각아이디문제언어결과실행 시간메모리
209465urd05콤보 (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

char s[4]={'A','B','X','Y'};

string guess_sequence(int n) {
	string st;
	st+=s[0];
	st+=s[1];
	int f;
	if (press(st)==1) {
		st.clear();
		st+=s[0];
		if (press(st)==1) {
			f=0;
		}
		else {
			f=1;
		}
	}
	else {
		st.clear();
		st+=s[2];
		if (press(st)==1) {
			f=2;
		}
		else {
			f=3;
		}
	}
	string ret;
	ret.push_back(s[f]);
	char one=0;
	char two=0;
	char three=0;
	for(int i=0;i<4;i++) {
		if (i!=f) {
          if (one==0) {
            one=s[i];
          }
          else if (two==0) {
            two=s[i];
          }
          else if (three==0) {
            three=s[i];
          }
		}
	}
	for(int i=1;i<n-1;i++) {
		string temp;
		temp+=ret;
		temp+=one;
		temp+=one;
		temp+=ret;
		temp+=one;
		temp+=two;
		temp+=ret;
		temp+=one;
		temp+=three;
		temp+=ret;
		temp+=two;
		int val=press(temp);
		if (val==i+2) {
			ret.push_back(one);
		}
		if (val==i+1) {
			ret.push_back(two);
		}
		if (val==i) {
			ret.push_back(three);
		}
	}
	string o;
	o+=ret;
	o+=one;
	string t;
	t+=ret;
	t+=two;
	if (press(o)==n) {
		ret.push_back(one);
	}
	else if (press(t)==n) {
		ret.push_back(two);
	}
	else {
		ret.push_back(three);
	}
	return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...