제출 #110947

#제출 시각아이디문제언어결과실행 시간메모리
110947CodeKracker콤보 (IOI18_combo)C++14
100 / 100
50 ms464 KiB
#include "combo.h" #include<bits/stdc++.h> #define FOR(i,a,b) for (int i = a; i < b; i++) #define FORD(i,a,b) for (int i = a; i >= b; i--) using namespace std; char gf(){ int c = press("AB"); if(c > 0){ int a = press("A"); if(a){ return 'A'; }else{ return 'B'; } }else{ int x = press("X"); if(x){ return 'X'; }else{ return 'Y'; } } } char gl(string ans,vector<char> vec){ int c = press(ans+vec[0]); if(c == ans.length()+1){ return vec[0]; } c = press(ans+vec[1]); if(c == ans.length()+1){ return vec[1]; } return vec[2]; } std::string guess_sequence(int n) { char f = gf(); vector<char> rem; string opt = "ABXY"; FOR(i,0,4){ if(opt[i] != f){ rem.push_back(opt[i]); } } string ans = ""; ans += f; FOR(i,1,n-1){ string cur = ans+rem[0]+ans+rem[1]+rem[0]+ans+rem[1]+rem[1]+ans+rem[1]+rem[2]; int c = press(cur); if(c == ans.length()){ ans += rem[2]; }else if(c == ans.length()+1){ ans += rem[0]; }else{ ans += rem[1]; } } if(n > 1){ char l = gl(ans,rem); ans += l; } return ans; }

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

combo.cpp: In function 'char gl(std::string, std::vector<char>)':
combo.cpp:28:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if(c == ans.length()+1){
      |      ~~^~~~~~~~~~~~~~~~~
combo.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if(c == ans.length()+1){
      |      ~~^~~~~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:52:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     if(c == ans.length()){
      |        ~~^~~~~~~~~~~~~~~
combo.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     }else if(c == ans.length()+1){
      |              ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...