제출 #1082995

#제출 시각아이디문제언어결과실행 시간메모리
1082995KasymK콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} string first_Letter_A(){ string ans = "A"; int x = 0; for(int i = 2; i < n; ++i){ int s = (int)ans.size(); x = press(ans+"X"+ans+"BX"+ans+"BB"+ans+"BY"); if(x == s+1) ans += "X"; else if(x == s+2) ans += "B"; else ans += "Y"; } if(press(ans+"B") == n) ans += "B"; else if(press(ans+"X") == n) ans += "X"; else ans += "Y"; return ans; } string first_Letter_B(){ string ans = "B"; int x = 0; for(int i = 2; i < n; ++i){ int s = (int)ans.size(); x = press(ans+"X"+ans+"AX"+ans+"AA"+ans+"AY"); if(x == s+1) ans += "X"; else if(x == s+2) ans += "A"; else ans += "Y"; } if(press(ans+"A") == n) ans += "A"; else if(press(ans+"X") == n) ans += "X"; else ans += "Y"; return ans; } string first_Letter_X(){ string ans = "X"; int x = 0; for(int i = 2; i < n; ++i){ int s = (int)ans.size(); x = press(ans+"A"+ans+"BA"+ans+"BB"+ans+"BY"); if(x == s+1) ans += "A"; else if(x == s+2) ans += "B"; else ans += "Y"; } if(press(ans+"A") == n) ans += "A"; else if(press(ans+"B") == n) ans += "B"; else ans += "Y"; return ans; } string first_Letter_Y(){ string ans = "Y"; int x = 0; for(int i = 2; i < n; ++i){ int s = (int)ans.size(); x = press(ans+"A"+ans+"BA"+ans+"BB"+ans+"BX"); if(x == s+1) ans += "A"; else if(x == s+2) ans += "B"; else ans += "X"; } if(press(ans+"B") == n) ans += "B"; else if(press(ans+"X") == n) ans += "X"; else ans += "A"; return ans; } string guess_sequence(int n){ if(n == 1){ string ans = ""; if(press("A")) ans += "A"; else if(press("B")) ans += "B"; else if(press("X")) ans += "X"; else ans += "Y"; return ans; } if(press("AB")){ if(press("A")) return first_Letter_A(); else return first_Letter_B(); } else{ if(press("X")) return first_Letter_X(); else return first_Letter_Y(); } assert(false); }

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

combo.cpp: In function 'std::string first_Letter_A()':
combo.cpp:20:24: error: 'n' was not declared in this scope
   20 |     for(int i = 2; i < n; ++i){
      |                        ^
combo.cpp:30:26: error: 'n' was not declared in this scope
   30 |     if(press(ans+"B") == n)
      |                          ^
combo.cpp: In function 'std::string first_Letter_B()':
combo.cpp:42:24: error: 'n' was not declared in this scope
   42 |     for(int i = 2; i < n; ++i){
      |                        ^
combo.cpp:52:26: error: 'n' was not declared in this scope
   52 |     if(press(ans+"A") == n)
      |                          ^
combo.cpp: In function 'std::string first_Letter_X()':
combo.cpp:64:24: error: 'n' was not declared in this scope
   64 |     for(int i = 2; i < n; ++i){
      |                        ^
combo.cpp:74:26: error: 'n' was not declared in this scope
   74 |     if(press(ans+"A") == n)
      |                          ^
combo.cpp: In function 'std::string first_Letter_Y()':
combo.cpp:86:24: error: 'n' was not declared in this scope
   86 |     for(int i = 2; i < n; ++i){
      |                        ^
combo.cpp:96:26: error: 'n' was not declared in this scope
   96 |     if(press(ans+"B") == n)
      |                          ^