제출 #1020732

#제출 시각아이디문제언어결과실행 시간메모리
1020732ZanP콤보 (IOI18_combo)C++17
0 / 100
0 ms344 KiB
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int press(string p); // { // cout << p << '\n'; // int a; cin >> a; // return a; // } int n; string z; string p; void make_bases() { if(z[0] == 'A'){ p = "XYB"; } else if(z[0] == 'B') { p = "AXY"; } else if(z[0] == 'X'){ p = "ABY"; } else if(z[0] == 'Y'){ p = "ABX"; } } string guess_sequence(int N) { n = N; z.reserve(n); int a = press("AB"); if(a == 2){z = "AB";} else if(a == 1){ if(press("A")){ z = "A"; }else{ z = "B"; } }else{ if(press("X")){ z = "X"; }else{ z = "Y"; } } make_bases(); while(true) { string ask = z; ask.push_back(p[0]); for (int i = 0; i<3;i++){ ask.append(z); ask.push_back(p[1]); ask.push_back(p[i]); } a = press(ask); if(a == z.size()) { z.push_back(p[2]); } else if(a == z.size()+1) { z.push_back(p[0]); } else { z.push_back(p[1]); } if(z.size() == n-1){break;} } for (int i = 0; i<2; i++) { string ask = z; ask.push_back(p[i]); a = press(ask); if(a == n) return ask; } z.push_back(p[2]); return z; } // int main() // { // int x; cin >> x; cout << guess_sequence(x) << '\n'; // return 0; // }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         if(a == z.size())
      |            ~~^~~~~~~~~~~
combo.cpp:64:19: 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(a == z.size()+1)
      |                 ~~^~~~~~~~~~~~~
combo.cpp:73:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   73 |         if(z.size() == n-1){break;}
      |            ~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...