제출 #1085128

#제출 시각아이디문제언어결과실행 시간메모리
1085128TlenekWodoru콤보 (IOI18_combo)C++17
100 / 100
24 ms1820 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; vector<char>Y={'A','B','X','Y'}; void usun(int u) { swap(Y[u],Y[Y.size()-1]); Y.pop_back(); } string guess_sequence(int n) { string odp; if(press("AB")==0) { if(press("X")==0) { odp.push_back('Y'); usun(3); } else { odp.push_back('X'); usun(2); } } else { if(press("A")==0) { odp.push_back('B'); usun(1); } else { odp.push_back('A'); usun(0); } } for(int i=2;i<n;i++) { string zap; zap+=odp; zap.push_back(Y[0]); zap.push_back(Y[0]); zap+=odp; zap.push_back(Y[0]); zap.push_back(Y[1]); zap+=odp; zap.push_back(Y[0]); zap.push_back(Y[2]); zap+=odp; zap.push_back(Y[1]); int u=press(zap); if(u==(int)odp.size()+2) { odp.push_back(Y[0]); } else if(u==(int)odp.size()+1) { odp.push_back(Y[1]); } else if(u==(int)odp.size()+0) { odp.push_back(Y[2]); } } string zap; zap+=odp; zap.push_back(Y[0]); zap+=odp; zap.push_back(Y[1]); if(n>1) if(press(zap)==(int)odp.size()) { odp.push_back(Y[2]); } else { zap.clear(); zap+=odp; zap.push_back(Y[0]); if(press(zap)==(int)odp.size()) { odp.push_back(Y[1]); } else { odp.push_back(Y[0]); } } return odp; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:72:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   72 |     if(n>1)
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...