제출 #585885

#제출 시각아이디문제언어결과실행 시간메모리
585885Valters07콤보 (IOI18_combo)C++14
100 / 100
38 ms592 KiB
#include <bits/stdc++.h> #include "combo.h" #pragma GCC optimize("O2,unroll-loops") #define fio ios_base::sync_with_stdio(0);cin.tie(0); #define ll long long #define en cin.close();return 0; #define pb push_back #define fi first//printf("%lli\n",cur); #define se second//scanf("%lli",&n); #define r0 return 0; using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); string conc(vector<char> ve) { string ret = ""; for(auto x:ve) ret+=x; return ret; } string guess_sequence(int n) { vector<char> ch = {'A','B','X','Y'}; char st = '?'; if(press(conc({ch[0],ch[1]}))>=1) st=(press(conc({ch[0]}))==1?ch[0]:ch[1]); else st=(press(conc({ch[2]}))==1?ch[2]:ch[3]); for(int i = 0;i<ch.size();i++) if(st==ch[i]) ch.erase(ch.begin()+i); string ans = ""; ans+=st; for(int i = 1;i<n-1;i++) { string constr = ""; constr+=ans; constr+=ch[1]; for(int j = 0;j<ch.size();j++) constr+=ans, constr+=ch[2], constr+=ch[j]; int t = press(constr); if(t==ans.size()) ans+=ch[0]; else if(t==ans.size()+1) ans+=ch[1]; else ans+=ch[2]; } if(n>1) { string constr = ans; constr+=ch[0]; if(press(constr)==n) ans+=ch[0]; else { constr.back()=ch[1]; if(press(constr)==n) ans+=ch[1]; else ans+=ch[2]; } } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0;i<ch.size();i++)
      |                   ~^~~~~~~~~~
combo.cpp:38:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int j = 0;j<ch.size();j++)
      |                       ~^~~~~~~~~~
combo.cpp:43:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if(t==ans.size())
      |            ~^~~~~~~~~~~~
combo.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         else if(t==ans.size()+1)
      |                 ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...