제출 #582720

#제출 시각아이디문제언어결과실행 시간메모리
582720TimDee콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define forn(i,n) for (int i=0; i<n; ++i) #define all(a) a.begin(), a.end() #define pb(x) push_back(x) std::string guess_sequence(int N) { int n=N; string s; //forn(i,n) s+='*'; char f; if (press("AB")) { if (press("A")) { f='A'; } else { f='B'; } } else { if (press("X")) { f='X'; } else { f='Y'; } } vector<char> v; if (f!='A') v.pb('A'); if (f!='B') v.pb('B'); if (f!='X') v.pb('X'); if (f!='Y') v.pb('Y'); s+=f; vector<char> Or; while (s.length()!=N) { string p=s; if (Or.size()) p+=Or[0]; p+=v[0]; p+=s; if (Or.size()) p+=Or[0]; p+=v[1]; int x = press(p); if (x==s.length() && x==p.length()/2-1) { if (Or.size()) { s+=Or[0]; Or.clear(); } s+=v[2]; } else if (x>s.length()){ if (Or.size()) s+=Or[0]; Or.clear(); Or.pb(v[0]); Or.pb(v[1]); } else { s+=Or[1]; Or.clear(); } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:14:7: error: 'press' was not declared in this scope
   14 |   if (press("AB")) {
      |       ^~~~~
combo.cpp:29:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   29 |   if (f!='A') v.pb('A'); if (f!='B') v.pb('B'); if (f!='X') v.pb('X'); if (f!='Y') v.pb('Y');
      |   ^~
combo.cpp:29:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |   if (f!='A') v.pb('A'); if (f!='B') v.pb('B'); if (f!='X') v.pb('X'); if (f!='Y') v.pb('Y');
      |                          ^~
combo.cpp:34:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   while (s.length()!=N) {
      |          ~~~~~~~~~~^~~
combo.cpp:43:13: error: 'press' was not declared in this scope
   43 |     int x = press(p);
      |             ^~~~~
combo.cpp:44:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if (x==s.length() && x==p.length()/2-1) {
      |         ~^~~~~~~~~~~~
combo.cpp:44:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if (x==s.length() && x==p.length()/2-1) {
      |                          ~^~~~~~~~~~~~~~~~
combo.cpp:51:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     else if (x>s.length()){
      |              ~^~~~~~~~~~~
combo.cpp:10:7: warning: unused variable 'n' [-Wunused-variable]
   10 |   int n=N;
      |       ^