제출 #1236587

#제출 시각아이디문제언어결과실행 시간메모리
1236587al_reem_2010콤보 (IOI18_combo)C++20
100 / 100
8 ms484 KiB
// اَللَهُمَ صَلِ عَلَىَ مُحَمَدٍ وَ آلِ مُحَمَدٍ
#include "combo.h"
#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <thread>
#include <fstream>
#include <stack>
using namespace std ;
//#define int long long
#define pb push_back
#define si size()
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define applejuice ios::sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ;
const int inf=1e18 ;
const int mod=1e9+7 ;
const int maxn=1e5+7 ;
int tt=1 ;
// A B X Y
/*namespace {

constexpr int MAX_N = 2000;
constexpr int MAX_NUM_MOVES = 8000;

int N;
std::string S;

int num_moves;

void wrong_answer(const char *MSG) {
  printf("Wrong Answer: %s\n", MSG);
  exit(0);
}

}  // namespace

int press(std::string p) {
  if (++num_moves > MAX_NUM_MOVES) {
    wrong_answer("too many moves");
  }
  int len = (int)p.size();
    cout << len << " " << p << " " << N << "\n" ;
  if (len > 4 * N) {
    wrong_answer("invalid press");
  }
  for (int i = 0; i < len; ++i) {
    if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') {
      wrong_answer("invalid press");
    }
  }
  int coins = 0;
  for (int i = 0, j = 0; i < len; ++i) {
    if (j < N && S[j] == p[i]) {
      ++j;
    } else if (S[0] == p[i]) {
      j = 1;
    } else {
      j = 0;
    }
    coins = std::max(coins, j);
  }
  return coins;
}*/
string guess_sequence(int n)
{
    string s="" , t ;
    if(press("AB")>=1)
    {
        if(press("A")==1) {s+='A' ; t="BXY" ;}
        else {s+='B' ; t="AXY" ;}
    }
    else
    {
        if(press("X")==1) {s+='X' ; t="ABY" ;}
        else {s+='Y' ; t="ABX" ;}
    }
    for(int i=1 ; i<n-1 ; i++)
    {
        int ans=press(s+t[1]+s+t[2]+t[0]+s+t[2]+t[1]+s+t[2]+t[2]) ;
        if(ans==s.si) {s+=t[0] ;}
        if(ans==s.si+1) {s+=t[1] ;}
        if(ans==s.si+2) {s+=t[2] ;}
    }
    if(n<2) {return s ;}
    if(press(s+t[0]+s+t[1])==s.si+1)
    {
        if(press(s+t[0])==s.si+1) {s+=t[0] ;}
        else {s+=t[1] ;}
    }
    else {s+=t[2] ;}
    return s ;
}
/*int main()
{
    cin >> S ;
    N=(int)S.si ;
    cout << guess_sequence(N) ;
    return 0 ;
}*/
/*
 ABXYY
 */

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

combo.cpp:23:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   23 | const int inf=1e18 ;
      |               ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...