제출 #300577

#제출 시각아이디문제언어결과실행 시간메모리
300577aymane7콤보 (IOI18_combo)C++17
97 / 100
36 ms612 KiB
#include<bits/stdc++.h> #include "combo.h" #pragma GCC optimize("O2") #define S second #define F first #define PB push_back #define sz(x) (int) x.size() #define all(x) x.begin(),x.end() #define L(x) 2*x #define R(x) 2*x+1 #define M(x,y) (x+y)/2 using namespace std; typedef long long ll; /* int press(string s){ cout<<s <<"?"<<endl; int ans; cin>>ans; return ans; } */ string guess_sequence(int n){ vector<string> pos; string ans; string f; if(press("A")){ ans="A"; pos.PB("B"); pos.PB("X"); pos.PB("Y"); } else if(press("B")){ ans="B"; pos.PB("A"); pos.PB("X"); pos.PB("Y"); } else if(press("X")){ ans="X"; pos.PB("A"); pos.PB("B"); pos.PB("Y"); } else{ ans="Y"; pos.PB("A"); pos.PB("B"); pos.PB("X"); } for(int i=2;i<=n-1;i++){ int cnt=0; string query=ans+pos[0]+ans+pos[1]+pos[0] +ans+pos[1]+pos[1] +ans+pos[1]+pos[2]; assert(sz(query)>=0 && sz(query)<=4*n); int q=press(query); if(q==sz(ans)) ans+=pos[2]; else if(q==sz(ans)+1) ans+=pos[0]; else ans+=pos[1]; } if(n==1){ return ans; } if(press(ans+pos[0])==n){ ans+=pos[0]; } else if(press(ans+pos[1])==n){ ans+=pos[1]; } else{ ans+=pos[2]; } return ans; } /* int main(){ cout<<guess_sequence(1); } */

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:13: warning: unused variable 'cnt' [-Wunused-variable]
   51 |         int cnt=0;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...