제출 #428864

#제출 시각아이디문제언어결과실행 시간메모리
428864Enkognit콤보 (IOI18_combo)C++14
5 / 100
1 ms456 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); } } ll k=2; //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); k++; if (p==ans.size()) ans+=z[2];else if (p==ans.size()+1) ans+=z[0];else ans+=z[1]; } //cout << k << "\n"; for (int j = 0; j < z.size()-1; j++) { string d=ans; d+=z[j]; ll p=press(d); if (p==ans.size()+1) { return d; } } ans+=z[2]; assert(ans.size()==n); //cout << ans << "\n"; return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     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:63:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |         assert(d.size()<=4*n);
      |                ~~~~~~~~^~~~~
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())
      |             ~^~~~~~~~~~~~
combo.cpp:69: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]
   69 |         if (p==ans.size()+1)
      |             ~^~~~~~~~~~~~~~
combo.cpp:76:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     for (int j = 0; j < z.size()-1; j++)
      |                     ~~^~~~~~~~~~~~
combo.cpp:81: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]
   81 |         if (p==ans.size()+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:87:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   87 |     assert(ans.size()==n);
      |            ~~~~~~~~~~^~~
combo.cpp:47:10: warning: unused variable 'lst' [-Wunused-variable]
   47 |     char lst='-';
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...