제출 #428907

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

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

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