Submission #99135

#TimeUsernameProblemLanguageResultExecution timeMemory
99135JustasLe콤보 (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
 
using namespace std;
 
string guess_sequence(int N) {
	set<char> X = {'A', 'B', 'X', 'Y'};
	string s = "";
	for (auto it = X.begin(); it != X.end(); it++) {
		int x = press(s + *it);
		if (x != 0) {
			s += *it;
			X.erase(it);
			break; 
		}
	}
	if (s == "") {
		return s;
	}
	int prev = 1;
	while (true) {
		int sz = (int) s.size(), c = 0;
		if (sz == N) {
			break;
		}
		if (sz == N - 1) {
			auto it = X.begin();
			if (press(s + *it) > press) {
				return (s + *it);
			}
			++it;
			if (press(s + *it) > press) {
				return (s + *it);
			}
			++it;
			return (s + *it);
		}
		// vector<string> extraX = {"XX", "XY", "XB"};
		// vector<string> extraA = {"AX", "AY", "AB"};
		// vector<string> extraB = {"BA", "BX", "BY"};
		// vector<string> extraY = {"YX", "YA", "YB"};
		if (s[0] == 'A') {
			int x = press(s + "Y" + s + "XX" + s + "XY" + s + "XB");
			if (x == prev) {
				s += "B";
				prev++;
				continue;
			} else {
				if (x == prev + 1) {
					s += "Y";
					prev++;
					continue;
				} else {
					s += "X";
					prev++;
					continue;
				}
			}
		}
		if (s[0] == 'B') {
			int x = press(s + "Y" + s + "XX" + s + "XY" + s + "XA");
			if (x == prev) {
				s += "A";
				prev++;
				continue;
			} else {
				if (x == prev + 1) {
					s += "Y";
					prev++;
					continue;
				} else {
					s += "X";
					prev++;
					continue;
				}
			}
		}
		if (s[0] == 'X') {
			int x = press(s + "Y" + s + "BB" + s + "BY" + s + "BA");
			if (x == prev) {
				s += "A";
				prev++;
				continue;
			} else {
				if (x == prev + 1) {
					s += "Y";
					prev++;
					continue;
				} else {
					s += "B";
					prev++;
					continue;
				}
			}
		}
		if (s[0] == 'Y') {
			int x = press(s + "B" + s + "XX" + s + "XB" + s + "XA");
			if (x == prev) {
				s += "A";
				prev++;
				continue;
			} else {
				if (x == prev + 1) {
					s += "B";
					prev++;
					continue;
				} else {
					s += "X";
					prev++;
					continue;
				}
			}
		}
	}
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   28 |    if (press(s + *it) > press) {
      |        ~~~~~~~~~~~~~~~^~~~~~~
combo.cpp:32:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   32 |    if (press(s + *it) > press) {
      |        ~~~~~~~~~~~~~~~^~~~~~~
combo.cpp:22:28: warning: unused variable 'c' [-Wunused-variable]
   22 |   int sz = (int) s.size(), c = 0;
      |                            ^
combo.cpp:7:35: warning: control reaches end of non-void function [-Wreturn-type]
    7 |  set<char> X = {'A', 'B', 'X', 'Y'};
      |                                   ^