제출 #75165

#제출 시각아이디문제언어결과실행 시간메모리
75165onjo0127콤보 (IOI18_combo)C++11
100 / 100
93 ms548 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; char C[4][3] = { {'B', 'X', 'Y'}, {'A', 'X', 'Y'}, {'A', 'B', 'Y'}, {'A', 'B', 'X'} }; char D[5] = "ABXY"; string ch(char st, string stk) { string S = ""; for(int i=0; i<stk.size(); i++) { if(stk[i] == 's') S += D[st - '0']; else S += C[st - '0'][stk[i] - '0']; } return S; } string guess_sequence(int N) { char st; if(press("AB") >= 1) { if(press("A") == 1) st = '0'; else st = '1'; } else { if(press("X") == 1) st = '2'; else st = '3'; } string stk; stk += 's'; int i; for(i=1; i<N-1; i++) { string P = ""; P += stk; P += "00"; P += stk; P += "01"; P += stk; P += "02"; P += stk; P += "10"; int tmp = press(ch(st, P)); if(tmp - i == -1) { stk.pop_back(); stk += "10"; } else if(tmp - i == 0) stk += '2'; else if(tmp - i == 1) stk += '1'; else if(tmp - i == 2) stk += '0'; } if(i == N) return ch(st, stk); int tmp = press(ch(st, stk + "0")); if(tmp < N-1) { stk.pop_back(); stk += "10"; return ch(st, stk); } if(tmp == N) return ch(st, stk + "0"); if(press(ch(st, stk + "1")) == N) return ch(st, stk + "1"); return ch(st, stk + "2"); }

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

combo.cpp: In function 'std::string ch(char, std::string)':
combo.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0; i<stk.size(); i++) {
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...