제출 #207712

#제출 시각아이디문제언어결과실행 시간메모리
207712Sho10콤보 (IOI18_combo)C++14
100 / 100
41 ms660 KiB
/* ID: Sho10 LANG: C++ */ #include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10 #include <combo.h> #define ll long long int #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define all(a) (a).begin(), (a).end() #define sz size #define f first #define s second #define pb push_back #define er erase #define in insert #define mp make_pair #define pi pair #define rc(s) return cout<<s,0 #define endl '\n' #define mod 1000000007 #define PI 3.14159265359 #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; /* ll n=5; string S="ABXYY"; int press(std::string p) { int coins = 0; for (int i = 0, j = 0; i < n; ++i) { if (j < n && S[j] == p[i]) { ++j; } else if (S[0] == p[i]) { j = 1; } else { j = 0; } coins = std::max(coins, j); } return coins; } */ string guess_sequence(int N){ ll n=N; string s="",ver="",x=""; ll a; a=press("AB"); if(a==2){ s=s+'A'; x=x+'A'; ver=ver+'B'; ver=ver+'X'; ver=ver+'Y'; }else if(a==1){ a=press("A"); if(a==1){ s=s+'A'; x=x+'A'; ver=ver+'B'; ver=ver+'X'; ver=ver+'Y'; }else{ s=s+'B'; x=x+'B'; ver=ver+'A'; ver=ver+'X'; ver=ver+'Y'; } }else { a=press("X"); if(a==1){ s=s+'X'; x=x+'X'; ver=ver+'A'; ver=ver+'B'; ver=ver+'Y'; }else { s=s+'Y'; x=x+'Y'; ver=ver+'A'; ver=ver+'B'; ver=ver+'X'; } } for(ll i=1;i<n;i++) { a=-1; if(i==n-1){ if(s[0]=='A'){ a=-1; }else { a=press((x+"A")); } if(a==n){ s=s+'A'; }else { if(s[0]=='B'){ a=-1; }else { a=press((x+"B")); } if(a==n){ s=s+'B'; }else { if(s[0]=='X'){ s=s+'Y'; }else if(s[0]=='Y'){ s=s+'X'; }else { a=press((x+"X")); if(a==n){ s=s+'X'; }else { s=s+'Y'; } } } } }else { a=press((x+ver[0]+x+ver[1]+ver[0]+x+ver[1]+ver[1]+x+ver[1]+ver[2])); if(a==x.size()){ s=s+ver[2]; x=x+ver[2]; }else if(a==x.size()+1){ s=s+ver[0]; x=x+ver[0]; }else { s=s+ver[1]; x=x+ver[1]; } } } return s; } /* int32_t main(){ CODE_START; cout<<guess_sequence(5)<<endl; } */

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

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