제출 #228367

#제출 시각아이디문제언어결과실행 시간메모리
228367Tehillah콤보 (IOI18_combo)C++14
100 / 100
40 ms696 KiB
#include <string> #include "combo.h" using namespace std; #define sz(a) (int)(a.size()) #define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i) string guess_sequence(int N) { string res = ""; char c[] = {'A', 'B', 'X', 'Y'}, f[3]; REP(i, 0, N) { string q = res; if(sz(res) > 0) { REP(j, 0, 4) { if(res[0] != c[j]) { if(sz(q) > sz(res)) { f[1] = c[j]; REP(k, 0, 4) if(c[k] != res[0]) q += res + c[j] + c[k]; break; } else q += c[j], f[0] = c[j]; } } REP(j, 0, 4) { if(c[j] == res[0]) continue; int done = 0; REP(k, 0, 2) if(c[j] == f[k]) {done = 1; break;} if(!done) {f[2] = c[j]; break;} } } if(sz(q) > 4*N || i == 0) { if(press(res + "A" + res + "B") >= i+1) res += ((press(res + "A") == i+1) ? 'A' : 'B'); else res += ((press(res + "X") == i+1) ? 'X' : 'Y'); } else { int ret = press(q); if(ret == i+1) res += f[0]; else if(ret == i+2) res += f[1]; else res += f[2]; } } return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:18: warning: 'f[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |     REP(k, 0, 2) if(c[j] == f[k]) {done = 1; break;}
      |                  ^~
combo.cpp:26:18: warning: 'f[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...