제출 #478299

#제출 시각아이디문제언어결과실행 시간메모리
478299ovidiush11콤보 (IOI18_combo)C++17
100 / 100
41 ms684 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; string guess_sequence(int n) { string s="",p=""; char a[4]; int c,k; p = "AB"; c = press(p); if(c == 2) { k = 2; s += p; } else if(c == 1) { if(press("A") == 1)s += "A"; else s += "B"; k = 1; } else { if(press("Y") == 1)s += "Y"; else s += "X"; k = 1; } a[0] = s[0]; if(a[0] == 'A') { a[1] = 'B';a[2] = 'X';a[3] = 'Y'; } else if(a[0] == 'B') { a[1] = 'A';a[2] = 'X';a[3] = 'Y'; } else if(a[0] == 'X') { a[1] = 'B';a[2] = 'A';a[3] = 'Y'; } else if(a[0] == 'Y') { a[1] = 'B';a[2] = 'X';a[3] = 'A'; } for(;k < n-1;k++) { p = s + a[1] + a[2] + s + a[1] + a[3] + s + a[1] + a[1] + s + a[2]; c = press(p); if(c == k + 2)s += a[1]; else if(c == k + 1)s += a[2]; else s += a[3]; } if(k == n)return s; p = s + a[1] + s + a[2]; c = press(p); if(c == n) { p = s + a[1]; if(press(p) == n)s += a[1]; else s += a[2]; } else s += a[3]; return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:49:45: warning: 'a[3]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |         p = s + a[1] + a[2] + s + a[1] + a[3] + s + a[1] + a[1] + s + a[2];
      |                                             ^
combo.cpp:56:27: warning: 'a[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |     p = s + a[1] + s + a[2];
      |                           ^
combo.cpp:56:16: warning: 'a[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |     p = s + a[1] + s + a[2];
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...