제출 #995634

#제출 시각아이디문제언어결과실행 시간메모리
995634mindiyak콤보 (IOI18_combo)C++14
5 / 100
1 ms596 KiB
#include "combo.h"

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef vector<ld> vd;
typedef vector<long long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;

string guess_sequence(int N) {
  vector<char> possible = {'A','B','X','Y'};
  string ans = "";
  if(press("AB")){
    if(press("A")){
      possible.erase(possible.begin());
      ans = "A";
    }
    else{
      possible.erase(possible.begin()+1);
      ans = "B";
    }
  }else{
    if(press("X")){
      possible.erase(possible.begin()+2);
      ans = "X";
    }
    else{
      possible.erase(possible.begin()+3);
      ans = "Y";
      }
  }

  FOR(i,0,N-2){
    string temp = ans + string(1,possible[0]);
    FOR(j,0,3)temp += ans + string(1,possible[1]) + string(1,possible[j]);
    int a = press(temp);
    if(a == ans.size()+1)ans += string(1,possible[0]);
    else if(a > ans.size()+1)ans += string(1,possible[1]);
    else ans += string(1,possible[2]);
  }

  FOR(j,0,2){
    int a = press(ans + string(1,possible[j]));
    if(a == N) return ans + string(1,possible[j]);
  }

  return ans + string(1,possible[2]);
}

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

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