제출 #138156

#제출 시각아이디문제언어결과실행 시간메모리
138156wilwxk콤보 (IOI18_combo)C++14
5 / 100
2 ms264 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN=2e3+5;
string atual, respf;
char opt[3];
int n;

std::string guess_sequence(int N) {
  n=N;
  atual="AB";
  if(press(atual)) {
    atual="A";
    if(press(atual)) respf=atual;
    else respf="B";
  }
  else {
    atual="X";
    if(press(atual)) respf=atual;
    else respf="Y";
  }
  opt[0]='A'; opt[1]='B'; opt[2]='X';
  for(int i=0; i<3; i++) if(opt[i]==respf[0]) opt[i]='Y';

  // cout << respf;

  while(respf.size()<n-1) {
    atual=respf;
    atual+=opt[1];
    atual+=(respf+opt[2]+opt[0]);
    atual+=(respf+opt[2]+opt[1]);
    atual+=(respf+opt[2]+opt[2]);
    // cout << "press " << atual << endl;
    int val=press(atual);
    if(val==respf.size()) respf+=opt[0];
    else if(val==respf.size()+1) respf+=opt[1];
    else respf+=opt[2];
  }

  int val=press(respf+opt[0]+respf+opt[1]);
  if(val>respf.size()) {
    val=press(respf+opt[0]);
    if(val>respf.size()) respf+=opt[0];
    else respf+=opt[1];
  }
  else {
    respf+=opt[2];
  }

  // cout << respf;

  return respf;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |   while(respf.size()<n-1) {
      |         ~~~~~~~~~~~~^~~~
combo.cpp:36:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     if(val==respf.size()) respf+=opt[0];
      |        ~~~^~~~~~~~~~~~~~
combo.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     else if(val==respf.size()+1) respf+=opt[1];
      |             ~~~^~~~~~~~~~~~~~~~
combo.cpp:42:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   if(val>respf.size()) {
      |      ~~~^~~~~~~~~~~~~
combo.cpp:44:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     if(val>respf.size()) respf+=opt[0];
      |        ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...