제출 #428698

#제출 시각아이디문제언어결과실행 시간메모리
428698Enkognit콤보 (IOI18_combo)C++14
94 / 100
64 ms492 KiB
#include <bits/stdc++.h> #include <vector> #include "combo.h" #define ll long long #define mp make_pair #define pb push_back #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second using namespace std; string guess_sequence(int n) { vector<char> z={'A', 'B', 'X', 'Y'}; string d; for (int i = 0; i < 2; i++) d+=z[i]; string ans; ll p=press(d); if (p) { p=press("A"); if (p) { ans+="A"; z.erase(z.begin()); }else { ans+="B"; z.erase(z.begin()+1); } }else { p=press("X"); if (p) { ans+="X"; z.erase(z.begin()+2); }else { ans+="Y"; z.erase(z.begin()+3); } } //cout << n << "\n"; char lst='-'; while (ans.size()<n-1) { //cout << ans << "\n"; string d=""; d+=ans; d+=z[0]; d+=ans; d+=z[1]; d+=z[0]; d+=ans; d+=z[1]; d+=z[1]; d+=ans; d+=z[1]; d+=z[2]; assert(d.size()<=4*n); //cout << " " << d << "\n"; ll p=press(d); if (p==ans.size()) ans+=z[2];else if (p==ans.size()+1) ans+=z[0];else ans+=z[1]; } for (int j = 0; j < z.size(); j++) { string d=ans; d+=z[j]; ll p=press(d); if (p==ans.size()+1) { ans+=z[j]; break; } } //cout << ans << "\n"; return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     while (ans.size()<n-1)
      |            ~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp:62:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |         assert(d.size()<=4*n);
      |                ~~~~~~~~^~~~~
combo.cpp:65:14: 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]
   65 |         if (p==ans.size())
      |             ~^~~~~~~~~~~~
combo.cpp:67:14: 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]
   67 |         if (p==ans.size()+1)
      |             ~^~~~~~~~~~~~~~
combo.cpp:71:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for (int j = 0; j < z.size(); j++)
      |                     ~~^~~~~~~~~~
combo.cpp:76:14: 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]
   76 |         if (p==ans.size()+1)
      |             ~^~~~~~~~~~~~~~
combo.cpp:46:10: warning: unused variable 'lst' [-Wunused-variable]
   46 |     char lst='-';
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...