제출 #1345326

#제출 시각아이디문제언어결과실행 시간메모리
1345326nanaseyuzuki콤보 (IOI18_combo)C++20
5 / 100
0 ms412 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
using namespace std;

#ifdef LOCAL
#include "C:\Users\Dell\Downloads\template\template\icpc-notebook\Utilities\debug.h"
#else
#define debug(...) 42
#endif

const int mn = 5e5 + 5, mod = 1e9 + 7, inf = 2e9;

string s, st; 

// int press(string x) {
// 	int mx = 0;
// 	for(int i = 0; i < (int) x.size(); i++) {
// 		int cnt = 0;
// 		while(true) {
// 			if(x[i + cnt] == st[cnt] && cnt < (int)st.size() - 1 && i + cnt < (int)x.size() - 1) cnt ++;
// 			else {
// 				if((cnt == (int) st.size() - 1 || i + cnt == (int)x.size() - 1) && x[i + cnt] == st[cnt]) cnt ++;
// 				mx = max(mx, cnt);
// 				break;
// 			}
// 			debug(i, cnt, mx);
// 		}
// 	}
// 	debug(x, st, mx);
// 	return mx;
// }

string guess_sequence(int n) {
	s.clear();
	int num = press("AB");
	char ban;
	if(num >= 1) {
		if(press("A") == 1) ban = 'A';
		else ban = 'B';
	}
	else {
		if(press("X") == 1) ban = 'X';
		else ban = 'Y';
	}
	s += ban;

  vector <char> all;
  for(auto x : {'A', 'B', 'X', 'Y'}) {
    if(x != ban) all.push_back(x);
  }
	for(int i = 1; i < n - 1; i++) {
	    string neww = s + all[0] + s + all[1] + all[0] + s + all[1] + all[1] + s + all[1] + all[2];
		int z = press(neww);
		if(z == i) s += all[2];
		else if(z == i + 1) s += all[0];
		else if(z == i + 2) s += all[1]; 
	}

	for(int i = 0; i <= 2; i++) {
		if(press(s + all[i]) == n) return s + all[i];
	}
}

// int main() {
// 	cin >> st;
// 	cout << guess_sequence(st.size()) << '\n';
// }
// Don't wanna lose anymore T_T
// Never let me go - Kazuo Ishiguro

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
   67 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...