제출 #576250

#제출 시각아이디문제언어결과실행 시간메모리
576250teki콤보 (IOI18_combo)C++11
100 / 100
37 ms636 KiB
#include <bits/stdc++.h> #include "combo.h" typedef long long ll; #define pb push_back #define MS(x,y) memset((x),(y),sizeof((x))) const ll MN = 1000000007; using namespace std; char seq[] = {'A','B','X','Y'}; //int press(string p) { // cout<<"? "<<p<<endl; // int br; // cin>>br; // return br; //} string guess_sequence(int n) { string curr; int ans1 = press("AB"); if (ans1 > 0) { int ans2 = press("A"); if (ans2 > 0) curr = "A"; else curr = "B"; } else { int ans2 = press("X"); if (ans2 > 0) curr = "X"; else curr = "Y"; } if (n == 1) return curr; for (int i = 1; i<n-1; i++) { string query; int ctr = 1; char koi[3]; for (int j = 0; j<4; j++) { if (curr[0] == seq[j]) continue; koi[ctr-1] = seq[j]; if (ctr == 1) query += curr+seq[j]; else if (ctr == 2) { string tmp = curr+seq[j]; for (int k = 0; k<4; k++) { if (curr[0] == seq[k]) continue; query += tmp+seq[k]; } } ctr++; } int ans = press(query); if (ans == curr.length()) curr += koi[2]; else if (ans == curr.length()+1) curr += koi[0]; else if (ans == curr.length()+2) curr += koi[1]; } char koi[3]; int ctr = 0; for (int i = 0; i<4; i++) { if (seq[i] == curr[0]) continue; koi[ctr] = seq[i]; if (ctr >= 2) break; string query = curr; query += seq[i]; if (press(query) >= n) { curr += seq[i]; break; } ctr++; } if (curr.length() < n) curr += koi[2]; return curr; } //int main() //{ // #if LOCAL_DEBUG // fstream cin("in.txt"); // #endif // // ios_base::sync_with_stdio(false); // cin.tie(0); // cout.tie(0); // // string secret = "A"; // cout<<guess_sequence(secret.length()); // // return 0; //}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:62:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         if (ans == curr.length()) curr += koi[2];
      |             ~~~~^~~~~~~~~~~~~~~~
combo.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         else if (ans == curr.length()+1) curr += koi[0];
      |                  ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:64:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         else if (ans == curr.length()+2) curr += koi[1];
      |                  ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:86:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   86 |     if (curr.length() < n) curr += koi[2];
      |         ~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...