제출 #996435

#제출 시각아이디문제언어결과실행 시간메모리
996435Icelast콤보 (IOI18_combo)C++17
100 / 100
27 ms1584 KiB
#include "combo.h" #include <iostream> #include <bits/stdc++.h> #define ll long long using namespace std; const ll maxn = 2*1e5+5, INF = 4e18+9; std::string guess_sequence(int N) { int n = N; string ss[4] = {"A", "B", "X", "Y"}; char c[4] = {'A', 'B', 'X', 'Y'}; string s; string t; t = s+"A"+s+"B"; if(press(t) > s.size()){ t = s+"A"; if(press(t) > s.size()){ s.push_back('A'); }else{ s.push_back('B'); } }else{ t = s+"X"; if(press(t)){ s.push_back('X'); }else{ s.push_back('Y'); } } if(n == 1) return s; for(int i = 2; i < n; i++){ string t; int cnt = 0; vector<int> d(3); for(int j = 0; j <= 3; j++){ if(s[0] == c[j]) continue; if(cnt == 2){ d[2] = j; break; } if(cnt == 0){ for(int k = 0; k <= 3; k++){ if(s[0] == c[k]) continue; t+=s; t.push_back(c[j]); t.push_back(c[k]); } d[0] = j; }else{ t+=s; t.push_back(c[j]); d[1] = j; } cnt++; } int res = press(t); if(res == 1+s.size()){ s.push_back(c[d[1]]); }else if(res == 2+s.size()){ s.push_back(c[d[0]]); }else{ s.push_back(c[d[2]]); } } t = s+"A"+s+"B"; if(press(t) > s.size()){ t = s+"A"; if(press(t) > s.size()){ s.push_back('A'); }else{ s.push_back('B'); } }else{ t = s+"X"; if(press(t) > s.size()){ s.push_back('X'); }else{ s.push_back('Y'); } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     if(press(t) > s.size()){
      |        ~~~~~~~~~^~~~~~~~~~
combo.cpp:17:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if(press(t) > s.size()){
      |            ~~~~~~~~~^~~~~~~~~~
combo.cpp:58:16: 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(res == 1+s.size()){
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:60:22: 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(res == 2+s.size()){
      |                  ~~~~^~~~~~~~~~~~~
combo.cpp:67:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     if(press(t) > s.size()){
      |        ~~~~~~~~~^~~~~~~~~~
combo.cpp:69:21: 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(t) > s.size()){
      |            ~~~~~~~~~^~~~~~~~~~
combo.cpp:76:21: 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(t) > s.size()){
      |            ~~~~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...