제출 #750057

#제출 시각아이디문제언어결과실행 시간메모리
750057Antonn_114콤보 (IOI18_combo)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; const string opt = "XYAB"; /* int press(string s){ cout << "? " << s << endl; int resp; cin >> resp; return resp; }*/ string guess_sequence(int n){ // check first char first_char; if (press("AB")){ if (press("A")){ first_char = 'A'; }else{ first_char = 'B'; } }else{ if (press("X")){ first_char = 'X'; }else{ first_char = 'Y'; } } string pref; pref += first_char; vector<string> mp; // if A is first_char -> // 0 -> XX // 1 -> XY // 2 -> XB // 3 -> YX // ... // 8 -> BB for (int i = 0; i < 4; i++){ for (int j = 0; j < 4; j++){ if (opt[i] == first_char || opt[j] == first_char) continue; mp.push_back(string{opt[i], opt[j]}); } } for (int i = 1; i < n - 1; i++){ string first_query = pref + mp[0] + pref + mp[1] + pref + mp[4]; int res1 = press(first_query); if (res1 == 0 + pref.length()){ pref += mp[6][0]; }else{ string second_query; if (res1 == 1 + pref.length()) second_query = pref + mp[3]; else second_query = pref + mp[0]; int res2 = press(second_query); if (res2 == 0 + pref.length()){ pref += (res1 == 1 ? mp[2] : mp[4]); }else if (res2 == 1 + pref.length()){ pref += (res1 == 1 ? mp[5] : mp[1]); }else{ pref += (res1 == 1 ? mp[3] : mp[0]); } i++; } } char last_char; if (press(pref + "AB") > pref.length()){ if (press(pref + "A") > pref.length()){ last_char = 'A'; }else{ last_char = 'B'; } }else{ if (press(pref + "X") > pref.length()){ last_char = 'X'; }else{ last_char = 'Y'; } } pref += last_char; return pref; } /* int main(){ int n; cin >> n; string s; s = guess_sequence(n); cout << "! " << s << endl; } */

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   if (res1 == 0 + pref.length()){
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:55:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |    if (res1 == 1 + pref.length()) second_query = pref + mp[3];
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:58:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    if (res2 == 0 + pref.length()){
      |        ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:60:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |    }else if (res2 == 1 + pref.length()){
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:69:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |  if (press(pref + "AB") > pref.length()){
      |      ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:70:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |   if (press(pref + "A") > pref.length()){
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:76:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |   if (press(pref + "X") > pref.length()){
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...