제출 #835535

#제출 시각아이디문제언어결과실행 시간메모리
835535KemalKCombo (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { string s = ""; string cur = "ABXY"; if (press(s + "AB")){ if (press(s + "A")){ s += "A"; } else{ s += "B"; } } else{ if (press(s + "X")){ s += "X"; } else{ s += "Y"; } } string rem = ""; for (int i = 0; i < 4; i++){ if (s[0] != cur[i]){ rem += cur[i]; } } int cnt = 1; if (n == 1){ return s; } for (int i = 1; i < n - 1; i++){ string p = s + rem[0]; for (int j = 0; j < 3; j++){ p += s + rem[1] + rem[j]; } int point = press(p); if (point == cnt + 1){ s += rem[0]; } else if (point == cnt + 2){ s += rem[1]; } else{ s += rem[2]; } cnt++; } assert(s.size() == n - 1); while(s.size() != n) if (press(s + rem[0]) == cnt + 1){ s += rem[0]; } else if (press(s + rem[1]) == cnt + 1){ s += rem[1]; } else{ s += rem[2]; } } return s; }

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

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:50:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |   assert(s.size() == n - 1);
      |          ~~~~~~~~~^~~~~~~~
combo.cpp:51:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |   while(s.size() != n)
      |         ~~~~~~~~~^~~~
combo.cpp: At global scope:
combo.cpp:62:3: error: expected unqualified-id before 'return'
   62 |   return s;
      |   ^~~~~~
combo.cpp:63:1: error: expected declaration before '}' token
   63 | }
      | ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:16: warning: control reaches end of non-void function [-Wreturn-type]
    6 |   string cur = "ABXY";
      |                ^~~~~~