제출 #228361

#제출 시각아이디문제언어결과실행 시간메모리
228361Tehillah콤보 (IOI18_combo)C++14
100 / 100
42 ms752 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; using ll = long long; #define pb push_back #define mkp make_pair #define ff first #define ss second #define all(a) a.begin(), a.end() #define sz(a) (int)(a.size()) #define clr(a, b) memset(a, b, sizeof(a)) #define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i) #define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i) #define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ ) template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); string guess_sequence(int N) { string res = ""; int ret = press("AB"); if(ret >= 1) { ret = press("A"); res += (ret == 1) ? 'A' : 'B'; } else { ret = press("X"); res += (ret == 1) ? 'X' : 'Y'; } char c[] = {'A', 'B', 'X', 'Y'}; char f[3]; REP(i, 1, N) { string q = res; 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; } if(!done) f[2] = c[j]; } if(sz(q) > 4*N) { ret = press(res + "A" + res + "B"); if(ret >= i+1) { ret = press(res + "A"); if(ret == i+1) res += 'A'; else res += 'B'; } else { ret = press(res + "X"); if(ret == i+1) res += 'X'; else res += 'Y'; } } else { 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:53:5: warning: 'f[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |     if(c[j] == f[k]) done = 1;
      |     ^~
combo.cpp:53:5: warning: 'f[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...