제출 #528600

#제출 시각아이디문제언어결과실행 시간메모리
528600groshi콤보 (IOI18_combo)C++17
100 / 100
35 ms540 KiB
#include<iostream> #include "combo.h" #include<string> using namespace std; string t[4]={"A","X","Y","B"}; string guess_sequence(int N) { string pocz; int gdzie; if(press("AB")) { if(press("A")) { pocz="A"; gdzie=0; } else{ pocz="B"; gdzie=3; } } else{ if(press("X")) { pocz="X"; gdzie=1; } else{ pocz="Y"; gdzie=2; } } if(N==1) return pocz; int czy=-1,jeden=-1,dwa=-1; for(int i=0;i<4;i++) { if(i==gdzie) continue; if(czy==-1) czy=i; else if(jeden==-1) jeden=i; else if(dwa==-1) dwa=i; } while(pocz.length()<=N-2) { int ile=press(pocz+t[czy]+pocz+t[jeden]+t[jeden]+pocz+t[jeden]+t[dwa]+pocz+t[jeden]+t[czy]); if(ile==pocz.length()+1) pocz+=t[czy]; else if(ile==pocz.length()+2) pocz+=t[jeden]; else pocz+=t[dwa]; } if(N>1) { int ile=0; for(int i=0;i<4;i++) { if(i==gdzie) continue; ile++; if(ile==3) { pocz+=t[i]; break; } if(press(pocz+t[i])==N) { pocz+=t[i]; break; } } } return pocz; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     while(pocz.length()<=N-2)
      |           ~~~~~~~~~~~~~^~~~~
combo.cpp:50:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         if(ile==pocz.length()+1)
      |            ~~~^~~~~~~~~~~~~~~~~
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(ile==pocz.length()+2)
      |                 ~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...