제출 #896117

#제출 시각아이디문제언어결과실행 시간메모리
896117wood콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> p32; typedef pair<ll,ll> p64; #define pb push_back #define eb emplace_back #define fi first #define se second #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) string guess_sequence(int n){ char start; if(press("AB")){ if(press("A")) start = 'A'; else start = 'B'; } else{ if(press("X")) start = 'X'; else start = 'Y'; } string p = ""; p+=start; vector<char> ch = {'A','B','X','Y'}; ch.erase(lower_bound(ch.begin(),ch.end(),start)); for (size_t i = 0; i < n-2; i++) { int guess = press(p+ch[0]+ch[0]+p+ch[0]+ch[1]+p+ch[0]+ch[2]+p+ch[1]); if(guess==p.size()+2) p+=ch[0]; else if(guess==p.size()+1) p+=ch[1]; else p+=ch[2]; } if(press(p+ch[0])==n) return p+ch[0]+'\n'; else if(press(p+ch[1])==n) return p+ch[1]+'\n'; else return p+ch[2]+'\n'; } int main() { fast_cin(); #ifndef ONLINE_JUDGE #ifdef _WIN32 freopen("input.in", "r", stdin); freopen("input.out", "w", stdout); #else freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif #endif int n; cin>>n; cout<<guess_sequence(n); return 0; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:8: error: 'press' was not declared in this scope
   15 |     if(press("AB")){
      |        ^~~~~
combo.cpp:29:26: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     for (size_t i = 0; i < n-2; i++)
      |                        ~~^~~~~
combo.cpp:31:21: error: 'press' was not declared in this scope
   31 |         int guess = press(p+ch[0]+ch[0]+p+ch[0]+ch[1]+p+ch[0]+ch[2]+p+ch[1]);
      |                     ^~~~~
combo.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if(guess==p.size()+2) p+=ch[0];
      |            ~~~~~^~~~~~~~~~~~
combo.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         else if(guess==p.size()+1) p+=ch[1];
      |                 ~~~~~^~~~~~~~~~~~
combo.cpp:36:8: error: 'press' was not declared in this scope
   36 |     if(press(p+ch[0])==n) return p+ch[0]+'\n';
      |        ^~~~~
combo.cpp:25:16: warning: control reaches end of non-void function [-Wreturn-type]
   25 |     string p = "";
      |                ^~
combo.cpp: In function 'int main()':
combo.cpp:48:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |             freopen(".in", "r", stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:49:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |             freopen(".out", "w", stdout);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~