제출 #1015903

#제출 시각아이디문제언어결과실행 시간메모리
1015903deera콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int press(string p); #include "combo.h" string guess(int N) { int a = press("AB"); int b = press("BX"); string f = ""; if (a == 1 && b == 1) { f += "B"; } if (a == 1 && b == 0) { f += "A"; } if (a == 0 && b == 1) { f += "X"; } if (a == 0 && b == 0) { f += "Y"; } if (f.size() == N) { return f; } vector<string> r; if (f != "A") r.push_back("A"); if (f != "B") r.push_back("B"); if (f != "X") r.push_back("X"); if (f != "Y") r.push_back("Y"); while (true) { string g = f + r[0] + f + r[1] + r[0] + f + r[1] + r[1] + f + r[1] + r[2]; if (g.size() > N * 4) { break; } else { int p = press(g); if (p == f.size()) { f += r[2]; } else if (p == f.size() + 1) { f += r[0]; } else if (p == f.size() + 2) { f += r[1]; } } } // guessing the last character int x = press(f + r[0] + f + r[1]) - f.size(); int y = press(f + r[0] + f + r[2]) - f.size(); if (x == 1 && y == 1) { f += r[0]; } if (x == 1 && y == 0) { f += r[1]; } if (x == 0 && y == 1) { f += r[2]; } if (x == 0 && y == 0) { // shouldn't happen } return f; }

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

combo.cpp: In function 'std::string guess(int)':
combo.cpp:27:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     if (f.size() == N) {
      |         ~~~~~~~~~^~~~
combo.cpp:41:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |         if (g.size() > N * 4) {
      |             ~~~~~~~~~^~~~~~~
combo.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             if (p == f.size()) {
      |                 ~~^~~~~~~~~~~
combo.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             } else if (p == f.size() + 1) {
      |                        ~~^~~~~~~~~~~~~~~
combo.cpp:49:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             } else if (p == f.size() + 2) {
      |                        ~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccGPfuAj.o: in function `main':
grader.cpp:(.text.startup+0x4c): undefined reference to `guess_sequence[abi:cxx11](int)'
collect2: error: ld returned 1 exit status