제출 #156288

#제출 시각아이디문제언어결과실행 시간메모리
156288a_player콤보 (IOI18_combo)C++14
100 / 100
52 ms532 KiB
#include <bits/stdc++.h> #define f first #define s second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; int press(string p); string c[4]; vector<string> v; string guess_sequence(int N){ string s=""; c[0]="A"; c[1]="B"; c[2]="X"; c[3]="Y"; int pos=-1; int x=press("AB"); if(x){ x=press("A"); if(x==1){ pos=0; s+="A"; }else{ pos=1; s+="B"; } }else{ x=press("X"); if(x==1){ pos=2; s+="X"; }else{ pos=3; s+="Y"; }} for(int i=0;i<4;i++)if(pos!=i)v.push_back(c[i]); for(int i=1;i<N-1;i++){ stringstream ss; ss<<s<<v[0]<<s<<v[1]<<v[0]<<s<<v[1]<<v[1]<<s<<v[1]<<v[2]; int a=press(ss.str()); if(a==(int)s.size()+1)s+=v[0]; else if(a==(int)s.size()+2)s+=v[1]; else s+=v[2]; } if(N>1){ int a=press(s+v[0]); if(a==s.size()+1)return s+v[0]; a=press(s+v[1]); if(a==s.size()+1)return s+v[1]; return s+v[2];} return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:52:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             if(a==s.size()+1)return s+v[0];
      |                ~^~~~~~~~~~~~
combo.cpp:54:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |      if(a==s.size()+1)return s+v[1];
      |         ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...