제출 #407414

#제출 시각아이디문제언어결과실행 시간메모리
407414ngrace콤보 (IOI18_combo)C++14
97 / 100
42 ms584 KiB
#include "combo.h" #include <string> #include <vector> #include <iostream> using namespace std; std::string guess_sequence(int N) { vector<char> but = {'A','B','X','Y'}; string s = ""; //find first char start='1'; for(char c : but){ if(c=='Y'){ s.push_back(c); start=c; break; } if(press(string(1,c))==1){ s.push_back(c); start=c; break; } } if(start=='A'){ but={'B','X','Y'}; } else if(start=='B'){ but={'A','X','Y'}; } else if(start=='X'){ but={'A','B','Y'}; } else{ but={'A','B','X'}; } for(int i=1;i<N-1;i++){ string q=""; q.append(s); q.push_back(but[0]); q.append(s); q.push_back(but[1]); q.push_back(but[0]); q.append(s); q.push_back(but[1]); q.push_back(but[1]); q.append(s); q.push_back(but[1]); q.push_back(but[2]); //cout<<q<<endl; int qu=press(q); if(qu==i+0){ s.push_back(but[2]); } else if(qu==i+1){ s.push_back(but[0]); } else{ s.push_back(but[1]); } //cout<<qu<<endl; //cout<<s.back()<<endl; } //now get last element if(s.size()<N){ for(int i=0;i<2;i++){ s.push_back(but[i]); if(press(s)==N){ break; } s.pop_back(); } if(s.size()<N){ s.push_back(but[2]); } } //cout<<s<<endl; return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:68:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |   if(s.size()<N){
      |      ~~~~~~~~^~
combo.cpp:76:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   76 |     if(s.size()<N){
      |        ~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...