제출 #345435

#제출 시각아이디문제언어결과실행 시간메모리
345435Iwanttobreakfree콤보 (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include "combo.h" using namespace std; string guess_sequence(int N) { string p; string S; int guardado; bool A,B,X,Y; p = "AB"; for (int i = 0; i < N-2; ++i) { p += 'B'; } int coins = press(p); if(coins==0){//Empieza x X o Y string p = "XA"; for (int i = 0; i < N-2; ++i) { p += 'A'; } int coins=press(p); if (coins==0){//Empieza x Y S[0]='Y'; Y=false; } else if (coins==1){//Empieza x X y no sigue A S[0]='X'; A=false; } else { for(int c=0;c<coins;c++){//Empieza x X y sigue A S[c]=p[c]; } A=false; } } else if(coins==1){//Empieza x A o x B p="BX"; for (int i = 0; i < N-2; ++i) { p += 'X'; } int coins=press(p); if(coins==0){//Empieza x A y no sigue B S[0]='A'; B=false; } else if (coins==1){//Empieza x B y no sigue X S[0]='B'; X=false; } else { for(int c=0;c<coins;c++){//Empieza x B y sigue X S[c]=p[c]; } X=false; } } else {//Empieza x A y sigue B for(int c=0;c<coins;c++){ S[c]=p[c]; } B=false; guardado=coins; } while(coins<N){ if (S[0]=='A'){ for (int i = 0; i < N-coins; ++i) { if (B) { S += 'B'; B=false; } else if (X) { S += 'X'; X=false; } else if (Y) { S += 'Y'; Y=false; } } } else if (S[0]=='B'){ for (int i = 0; i < N-coins; ++i) { if (A) { S += 'A'; A=false; } else if (X) { S += 'X'; X=false; } else if (Y) { S += 'Y'; Y=false; } } } else if (S[0]=='X'){ for (int i = 0; i < N-coins; ++i) { if (A) { S += 'A'; A=false; } else if (B) { S += 'B'; B=false; } else if (Y) { S += 'Y'; Y=false; } } } else if (S[0]=='Y'){ for (int i = 0; i < N-coins; ++i) { if (A) { S += 'A'; A=false; } else if (B) { S += 'B'; B=false; } else if (X) { S += 'X'; X=false; } } } int coins=press(S); if (coins>guardado){ A=true; B=true; X=true; Y=true; guardado=coins; } } return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:133:4: warning: 'guardado' may be used uninitialized in this function [-Wmaybe-uninitialized]
  133 |    if (coins>guardado){
      |    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...