제출 #284296

#제출 시각아이디문제언어결과실행 시간메모리
284296MKopchev콤보 (IOI18_combo)C++14
100 / 100
43 ms664 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; string guess_sequence(int N) { string start=""; if(press("AB")) { if(press("A"))start="A"; else start="B"; } else { if(press("X"))start="X"; else start="Y"; } if(N==1)return start; string other=""; if(start[0]!='A')other.push_back('A'); if(start[0]!='B')other.push_back('B'); if(start[0]!='X')other.push_back('X'); if(start[0]!='Y')other.push_back('Y'); for(int i=2;i<N;i++) { //cout<<"start= "<<start<<endl; string cur=start; cur.push_back(other[0]); cur=cur+start; cur.push_back(other[1]); cur.push_back(other[0]); cur=cur+start; cur.push_back(other[1]); cur.push_back(other[1]); cur=cur+start; cur.push_back(other[1]); cur.push_back(other[2]); int val=press(cur); if(val==start.size())start.push_back(other[2]); else if(val==start.size()+1)start.push_back(other[0]); else start.push_back(other[1]); } string cur; cur=start; cur.push_back(other[0]); if(press(cur)==N)return cur; cur=start; cur.push_back(other[1]); if(press(cur)==N)return cur; cur=start; cur.push_back(other[2]); return cur; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         if(val==start.size())start.push_back(other[2]);
      |            ~~~^~~~~~~~~~~~~~
combo.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         else if(val==start.size()+1)start.push_back(other[0]);
      |                 ~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...