제출 #971294

#제출 시각아이디문제언어결과실행 시간메모리
971294codefox콤보 (IOI18_combo)C++14
100 / 100
20 ms2204 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; char unknown(string s, int j, char f) { string ss = ""; string sol; for (int i = 0; i < j; i++) { ss+=s[i]; } if (f=='A') { sol = ss+'B'; sol += ss+"XX"; sol += ss+"XB"; sol += ss+"XY"; int c = press(sol); if (c==j) return 'Y'; if (c==j+1) return 'B'; else return 'X'; } if (f=='B') { sol = ss+'A'; sol += ss+"XX"; sol += ss+"XA"; sol += ss+"XY"; int c = press(sol); if (c==j) return 'Y'; if (c==j+1) return 'A'; else return 'X'; } if (f=='Y') { sol = ss+'A'; sol += ss+"BX"; sol += ss+"BB"; sol += ss+"BA"; int c = press(sol); if (c==j) return 'X'; if (c==j+1) return 'A'; else return 'B'; } if (f=='X') { sol = ss+'B'; sol += ss+"AA"; sol += ss+"AB"; sol += ss+"AY"; int c = press(sol); if (c==j) return 'Y'; if (c==j+1) return 'B'; else return 'A'; } } string guess_sequence(int N) { char f = 'N'; int a = press("XA"); int b = press("YA"); if (a && b) f = 'A'; else if (a) f = 'X'; else if (b) f = 'Y'; else f = 'B'; if (N==1) { string s = ""; s+=f; return s; } string s = ""; s += f; for (int i = 1; i < N-1; i++) { s += unknown(s, i, f); } if (f!='A' && press(s+'A')==N) return s+'A'; if (f!='B' && press(s+'B')==N) return s+'B'; if (f =='X') return s+'Y'; if (f=='Y') return s+'X'; if (press(s+'Y')==N) return s+'Y'; else return s+'X'; }

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

combo.cpp: In function 'char unknown(std::string, int, char)':
combo.cpp:8:17: warning: control reaches end of non-void function [-Wreturn-type]
    8 |     string ss = "";
      |                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...