제출 #143898

#제출 시각아이디문제언어결과실행 시간메모리
143898Nightlight콤보 (IOI18_combo)C++14
100 / 100
71 ms512 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string res = ""; vector<string> guess = {"A", "B", "X", "Y"}; int coins = press("AB"); if(coins){ if(press("A"))res += 'A'; else res += 'B'; }else{ if(press("X"))res += 'X'; else res += 'Y'; } for(int i = 0; i < 4; i++){ if(res == guess[i])guess.erase(guess.begin() + i); } if(N > 1){ for(int i = 1; i < (N-1); i++){ string temp = res + guess[0]; for(auto i : guess){ temp += res + guess[1] + i; } int respon = press(temp); if(respon == res.length()){ res += guess[2]; }else if(respon == res.length() + 1){ res += guess[0]; }else res += guess[1]; } coins = press(res + guess[0] + res + guess[1]); if(coins == res.length() + 1){ if(press(res + guess[0]) == res.length() + 1)res += guess[0]; else res += guess[1]; }else res += guess[2]; // cout << res << "\n"; } return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |       if(respon == res.length()){
      |          ~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |       }else if(respon == res.length() + 1){
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:34:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if(coins == res.length() + 1){
      |        ~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:35:32: 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(press(res + guess[0]) == res.length() + 1)res += guess[0];
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...