제출 #592804

#제출 시각아이디문제언어결과실행 시간메모리
592804Summers콤보 (IOI18_combo)C++14
5 / 100
1 ms272 KiB
#include "combo.h" #include<iostream> using namespace std; std::string guess_sequence(int n) { string s,s1; long long br=1,le=0; char cc; char m[10]={'A','B','X','Y'}; if(press("XY")) { if(press("X")){s="X";cc='X';} else {s="Y";cc='Y';} } else if(press("A")){s="A";cc='A';} else {s="B";cc='B';} char c[2]; for(int i=0;i<=3;i++) { if(m[i]!=cc)c[le++]=m[i]; } while(br<n-1) { s1=s+c[0]+c[1]+s+c[0]+c[0]+s+c[0]+c[2]+s+c[1]; long long is=press(s1); if(is==br){s=s+c[2];br++;continue;} if(is==br+1){s=s+c[1];br++;continue;} s=s+c[0];br++;continue; } if(press(s+c[0])==br+1)s+=c[0]; else if(press(s+c[1])==br+1)s+=c[1]; else s+=c[2]; return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:43: warning: array subscript 2 is above array bounds of 'char [2]' [-Warray-bounds]
   27 |      s1=s+c[0]+c[1]+s+c[0]+c[0]+s+c[0]+c[2]+s+c[1];
      |                                        ~~~^
combo.cpp:19:9: note: while referencing 'c'
   19 |    char c[2];
      |         ^
combo.cpp:37:14: warning: array subscript 2 is above array bounds of 'char [2]' [-Warray-bounds]
   37 |   else s+=c[2];
      |           ~~~^
combo.cpp:19:9: note: while referencing 'c'
   19 |    char c[2];
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...