제출 #103819

#제출 시각아이디문제언어결과실행 시간메모리
103819beso123콤보 (IOI18_combo)C++14
100 / 100
41 ms556 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; /*string pas; int qu; int press(string s){ qu++; int r=0; string b=""; for(int k=0;k<pas.size();k++){ b=b+pas[k]; if(s.find(b)==-1) return r; r++; } return r; }*/ string a="ABXY"; string guess_sequence(int N){ if(N==1){ if(press("A")==1) return "A"; if(press("B")==1) return "B"; if(press("X")==1) return "X"; return "Y"; } string s=""; int num,i=0; string b; s=a[0]; s+=a[1]; num=press(s); if(num>=1){ s=a[0]; if(press(s)==1){ b+=s; a.erase(0,1); } else{ b+=a[1]; a.erase(1,1); } } else{ s=a[2]; if(press(s)){ b+=s; a.erase(2,1); } else{ b+=a[3]; a.erase(3,1); } } while((int)b.size()<N-1){ string c=b+a[0]+b+a[1]+a[0]+b+a[1]+a[2]+b+a[1]+a[1]; int ps=press(c); if(ps==b.size()) b+=a[2]; else{ if(ps==b.size()+1) b+=a[0]; else if(ps==b.size()+2) b+=a[1]; } } s=b+a[0]; if(press(s)==b.size()+1) return s; s=b+a[1]; if(press(s)==b.size()+1) return s; s=b+a[2]; return s; } /*int main(){ while(1){ qu=0; a="ABXY"; cin>>pas; string s=guess_sequence(pas.size()); cout<<s<<' '<<qu<<endl; } return 0; }*/

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   if(ps==b.size())
      |      ~~^~~~~~~~~~
combo.cpp:63:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   if(ps==b.size()+1)
      |      ~~^~~~~~~~~~~~
combo.cpp:66:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   if(ps==b.size()+2)
      |      ~~^~~~~~~~~~~~
combo.cpp:71:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 | if(press(s)==b.size()+1)
      |    ~~~~~~~~^~~~~~~~~~~~
combo.cpp:75:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 | if(press(s)==b.size()+1)
      |    ~~~~~~~~^~~~~~~~~~~~
combo.cpp:30:9: warning: unused variable 'i' [-Wunused-variable]
   30 | int num,i=0;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...