Submission #76518

# Submission time Handle Problem Language Result Execution time Memory
76518 2018-09-14T11:52:53 Z darthsidious Combo (IOI18_combo) C++14
0 / 100
2 ms 200 KB
#include <iostream>
#include <string>
//A B X Y

using namespace std;

int press(string p);
// {
// 	string secret = "ABXYXXYY";
// 	int ans = 0;
// 	for(int i=0;i<secret.size();i++) {
// 		if(secret[i] == p[i])
// 			ans++;
// 		else
// 			break;
// 	}
// 	return ans;
// }

string guess_sequence(int N) {
	string chars = "ABXY";
	string c[3];
	int start_c = 3;
	
	int x = press("AB");
	// cout << "x = " << x << endl;
	if(x > 1) {
		if(press("A") == 1)
			start_c = 0;
		else
			start_c = 1;
	}
	else {
		if(press("X") == 1)
			start_c = 2;
	}

	// for(int i=0;i<3;i++) {
	// 	string tmp(1, chars[i]);
	// 	int r = press(tmp);	
	// 	if(r == 1) {
	// 		start_c = i;
	// 		break;
	// 	}
	// }

	for(int i=0;i<3;i++) {
		if(start_c <= i)
			c[i] = string(1, chars[i+1]);
		else
			c[i] = string(1, chars[i]);
	}
	// cout << c[0] << c[1] << c[2] << endl;	

	string ans(1, chars[start_c]);
	// cout << "Starting with " << ans << endl;
	for(int i=0;i<7996;i++) {

		int correct = ans.size();
		if(correct == N)
			break;

		if(correct == N -1) {
			int r;
			for(int k=0;k<3;k++) {
				r = press(ans + c[k]);
				if(r == N)
					return ans + c[k];
			}
			return ans;
		}

		string test = ans + c[0] + ans + c[1] + c[0] + ans + c[1] + c[1] + ans + c[1] + c[2];
		if(test.size() > 4*N)
			cout << "wtf";
		int res = press(test);
		// cout << "Result: " << res << " test: " << test << " correct: " << correct << endl;

		if(res == correct)
			ans += c[2];
		else if(res == correct + 1)
			ans += c[0];
		else if(res == correct + 2)
			ans += c[1];
		// cout << "testing " << test << endl;


		if((int)ans.size() == N)
			break;
	}

	return ans;
}

// int main() {
// 	cout << guess_sequence(8) << endl;
// }

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:74:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 |   if(test.size() > 4*N)
      |      ~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Incorrect 1 ms 200 KB Wrong Answer: wrong guess.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Wrong Answer: wrong guess.
2 Halted 0 ms 0 KB -