제출 #624326

#제출 시각아이디문제언어결과실행 시간메모리
624326speedyArda콤보 (IOI18_combo)C++14
0 / 100
1 ms208 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; string letters[4] = {"A", "B", "X", "Y"}; string guess_sequence(int N) { string res = ""; int forbidden = 0; for(int idx = 0; idx < 3; idx++) { string i = letters[idx]; int num = press(i); //cout << i << "\n"; //int num; //cin >> num; if(num == 1) { res = i; forbidden = idx; break; } } if(res.size() == 0) { res = "Y"; forbidden = 3; } string available[3]; for(int i = 0; i < 4; i++) { if(forbidden == i) continue; if(i < forbidden) available[i] = letters[i]; else available[i - 1] = letters[i]; } int last; while(res.size() < N) { string temp = ""; for(int i = 0; i <= 2; i++) { if(res.size() + 1 == N && last != 0) continue; temp += res + available[0] + available[i]; } if(res.size() + 1 < N || (res.size() + 1 == N && last != 0)) temp += res + available[1]; int num = press(temp); //cout << temp << "\n"; //int num; //cin >> num; if(num == res.size()) { res += available[2]; last = 2; } else if(num - 1 == res.size()) { res += available[1]; last = 1; } else { res += available[0]; last = 0; } } return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     while(res.size() < N)
      |           ~~~~~~~~~~~^~~
combo.cpp:43:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |             if(res.size() + 1 == N && last != 0)
      |                ~~~~~~~~~~~~~~~^~~~
combo.cpp:47:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         if(res.size() + 1 < N || (res.size() + 1 == N && last != 0))
      |            ~~~~~~~~~~~~~~~^~~
combo.cpp:47:50: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         if(res.size() + 1 < N || (res.size() + 1 == N && last != 0))
      |                                   ~~~~~~~~~~~~~~~^~~~
combo.cpp:53:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         if(num == res.size()) {
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:57:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         else if(num - 1 == res.size()) {
      |                 ~~~~~~~~^~~~~~~~~~~~~
combo.cpp:43:36: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |             if(res.size() + 1 == N && last != 0)
      |                ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...