제출 #1032461

#제출 시각아이디문제언어결과실행 시간메모리
1032461ThommyDB콤보 (IOI18_combo)C++17
0 / 100
1 ms344 KiB
#include "combo.h"
#include<bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
  string p = "";
  if(press("AB")>=1){
    if(press("A") >= 1) p+="A";
    else p+="B";
  }
  else{
    if(press("X") >= 1) p+="X";
    else p+="Y";
  }
  if(N==1)return p;

  vector<int> a;
  for(auto u : "ABXY"){
    if(u!=p[0]) a.push_back(u);
  }

  for(int i = 1; i<N-1; i++){
    string s = "";
    s+=p;s+=p;s+=p;s+=p;s.push_back(a[0]);s.push_back(a[0]);s.push_back(a[1]);s.push_back(a[1]);s.push_back(a[1]);s.push_back(a[1]);s.push_back(a[2]);

    int v = press(s);
    if(v == p.length() +1) p+=a[0];
    else if(v==p.length()+2) p+=a[1];
    else p+=a[2];
  }
  p.push_back(a[0]);
  if(press(p) != N) {p.pop_back(); p.push_back(a[1]);}
  else if(press(p)!=N) p.pop_back();
  else p+=a[2];
  return p;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     if(v == p.length() +1) p+=a[0];
      |        ~~^~~~~~~~~~~~~~~~
combo.cpp:29:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     else if(v==p.length()+2) p+=a[1];
      |             ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...