제출 #760921

#제출 시각아이디문제언어결과실행 시간메모리
760921midi콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include "combo.h" #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'}; string S = "ABXYY"; 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 'void init(char)':
combo.cpp:30:2: error: 'A' was not declared in this scope
   30 |  A = tar[i++];
      |  ^
combo.cpp:31:2: error: 'B' was not declared in this scope
   31 |  B = tar[i++];
      |  ^
combo.cpp:32:2: error: 'C' was not declared in this scope
   32 |  C = tar[i++];
      |  ^
combo.cpp:33:2: error: 'D' was not declared in this scope
   33 |  D = tar[i++];
      |  ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:64:13: error: 'A' was not declared in this scope
   64 |  builder.pb(A);
      |             ^
combo.cpp:74:12: error: 'B' was not declared in this scope
   74 |   adder.pb(B);
      |            ^
combo.cpp:79:12: error: 'C' was not declared in this scope
   79 |   adder.pb(C); adder.pb(B);
      |            ^
combo.cpp:89:25: error: 'D' was not declared in this scope
   89 |   adder.pb(C); adder.pb(D);
      |                         ^
combo.cpp:103:13: error: 'B' was not declared in this scope
  103 |  builder.pb(B);
      |             ^
combo.cpp:107:20: error: 'C' was not declared in this scope
  107 |   builder.back() = C;
      |                    ^
combo.cpp:111:21: error: 'D' was not declared in this scope
  111 |    builder.back() = D;
      |                     ^