제출 #549461

#제출 시각아이디문제언어결과실행 시간메모리
549461esomer콤보 (IOI18_combo)C++17
100 / 100
30 ms564 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ans = ""; vector<string> pos; int x = press("XY"); // if(x == 2) {ans = "XY"; pos = {"Y", "A", "B"};} else if(x == 1){ x = press("X"); // if(x) {ans = "X"; pos = {"Y", "A", "B"};} else {ans = "Y"; pos = {"X", "A", "B"};} }else{ x = press("A"); // if(x) {ans = "A"; pos = {"Y", "X", "B"};} else {ans = "B"; pos = {"Y", "A", "X"};} } while(ans.size() + 2 <= N){ ans += pos[0]; ans += pos[1]; string ss = ans; ans.pop_back(); ans += pos[0]; ss += ans; ans.pop_back(); ans.pop_back(); ans += pos[1]; ans += pos[1]; ss += ans; x = press(ss); // ans.pop_back(); ans.pop_back(); if(x == ans.size() + 2){ ans += pos[0]; ans += pos[0]; x = press(ans); // ans.pop_back(); ans.pop_back(); if(x == ans.size() + 1){ ans += pos[0]; ans += pos[1]; }else if(x == ans.size()){ ans += pos[1]; ans += pos[1]; }else{ ans += pos[0]; ans += pos[0]; } }else if(x == ans.size() + 1){ ans += pos[1]; ans += pos[2]; x = press(ans); // ans.pop_back(); ans.pop_back(); if(x == ans.size() + 1){ ans += pos[1]; ans += pos[0]; }else if(x == ans.size()){ ans += pos[0]; ans += pos[2]; }else{ ans += pos[1]; ans += pos[2]; } }else ans += pos[2]; } if(ans.size() == N) return ans; else{ ans += pos[0]; x = press(ans); // if(x == N) return ans; else{ ans.pop_back(); ans += pos[1]; x = press(ans); // if(x == N) return ans; else{ ans.pop_back(); ans += pos[2]; return ans; } } } }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |   while(ans.size() + 2 <= N){
      |         ~~~~~~~~~~~~~~~^~~~
combo.cpp:35:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if(x == ans.size() + 2){
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:41:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |       if(x == ans.size() + 1){
      |          ~~^~~~~~~~~~~~~~~~~
combo.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |       }else if(x == ans.size()){
      |                ~~^~~~~~~~~~~~~
combo.cpp:51:16: 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 == ans.size() + 1){
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:57:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |       if(x == ans.size() + 1){
      |          ~~^~~~~~~~~~~~~~~~~
combo.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |       }else if(x == ans.size()){
      |                ~~^~~~~~~~~~~~~
combo.cpp:69:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |   if(ans.size() == N) return ans;
      |      ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...