제출 #760920

#제출 시각아이디문제언어결과실행 시간메모리
760920midi콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vcll; typedef vector<int> vci; typedef pair<ll, ll> prll; typedef pair<int, int> prii; #define f0r(i, a, n) for (i = a; i < n; i++) #define f1r(i, a, n) for (i = a; i <= n; i++) #define r0f(i, n, a) for (i = n; i > a; i--) #define r1f(i, n, a) for (i = n; i >= a; i--) #define pb push_back char tar[] = {'A', 'B', 'X', 'Y', 'A', 'B', 'X'}; char A, B, C, D; void init(char start) { ll n = sizeof(tar); ll i; f0r(i, 0, n) if (tar[i] == start) break; A = tar[i++]; B = tar[i++]; C = tar[i++]; D = tar[i++]; } void paste(string &from, string &to) { for (auto const &c : from) to.pb(c); } string guess_sequence(int N) { ll n = N; string builder; ll res = press("AB"); char start; if (res) { res = press("A"); if (res) start = 'A'; else start = 'B'; } else { res = press("X"); if (res) start = 'X'; else start = 'Y'; } init(start); builder.pb(A); // first char, done ll i = 0; string pusher, adder; f0r(i, 1, n) { paste(builder, pusher); adder.pb(B); paste(adder, pusher); adder.clear(); paste(builder, pusher); adder.pb(C); adder.pb(B); paste(adder, pusher); adder.clear(); paste(builder, pusher); adder.pb(C); adder.pb(C); paste(adder, pusher); adder.clear(); paste(builder, pusher); adder.pb(C); adder.pb(D); paste(adder, pusher); adder.clear(); res = press(pusher); pusher.clear(); if (res == i) builder.pb(D); else if (res == i + 1) builder.pb(B); else builder.pb(C); } // all the middles, done builder.pb(B); res = press(builder); if (res != n) { builder.back() = C; res = press(builder); if (res != n) { builder.back() = D; } } return builder; // last char }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:11: error: 'press' was not declared in this scope; did you mean 'res'?
   45 |  ll res = press("AB");
      |           ^~~~~
      |           res