제출 #447539

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define pb push_back
#define popb pop_back
#define ff first
#define ss second
const int MOD = 1e9 + 7;
const ll INF = 1e18;


string guess_sequence(int n)
{
    char but[4] = {'A','B','X','Y'};
  string p = "";
  string s = "";
  int fr = -1;
  for(int i = 0; i < 4; i ++)
  {
      string g = p + but[i];
      int rep = press(g);
      if(rep == 1)
      {
          fr = i;
          s = g;
          break;
      }
  }
  but[3] = but[fr];
  but[fr] = 'Y';
  for(int i = 1; i < n - 1; i ++)
  {
     char b = but[0];
     char x= but[1];
     char y = but[2];
     string g = s + b;
     g += (s+ x + x);
     g += (s+ x + b);
     g += (s+ x + y);
     int tent = press(g);
     if(tent == s.length() +1)
     {
         s += b;
     }
     else if(tent == s.length() + 2)
     {
         s += x;
     }
     else
     {
         s += y;
     }
  }
  for(int j = 0; j < 3; j ++)
  {
      string g = s + but[j];
      int tent = press(g);
      if(tent == n)
      {
          s += but[j];
          break;
      }
  }
  return s;
}

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

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