Submission #632447

#TimeUsernameProblemLanguageResultExecution timeMemory
632447ghostwriterCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
    Tran The Bao
    CTL - Da Lat
    Practising for VOI23 gold medal
*/
int n;
str s;
#ifdef LOCAL
	int press(str p) {
		int rs = 0;
		FOR(i, 1, n) {
			str tmp = s.substr(1, i);
			FOR(j, 0, sz(p) - i) {
				str tmp1 = p.substr(j, i);
				if (tmp1 == tmp) rs = max(rs, i);
			}
		}
		return rs;
	}
#endif
str guess_sequence(int N) {
	const vi c = {'A', 'B', 'X', 'Y'};
	str ans;
	FOR(i, 1, N)
	FOR(j, 0, 3) {
		ans.pb(c[j]);
		if (press(ans) == i) break;
		ans._pb();
	}
	return ans;
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);
    #ifdef LOCAL
    	cin >> s;
    	n = sz(s);
    	s = "#" + s + "#";
    	cout << guess_sequence(n);
	#endif
    return 0;
}

Compilation message (stderr)

combo.cpp: In function 'str guess_sequence(int)':
combo.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
combo.cpp:54:2: note: in expansion of macro 'FOR'
   54 |  FOR(i, 1, N)
      |  ^~~
combo.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
combo.cpp:55:2: note: in expansion of macro 'FOR'
   55 |  FOR(j, 0, 3) {
      |  ^~~
combo.cpp:57:7: error: 'press' was not declared in this scope
   57 |   if (press(ans) == i) break;
      |       ^~~~~