제출 #101688

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

string s="ABXY";
string rest;
string ans;

string guess_sequence(int n)
{
    int ret=press("AB");
    if (ret>0)
    {
        ret=press("A");
        if (ret>0) ans+="A";
        else ans+="B";
    }
    else
    {
        ret=press("X");
        if (ret>0) ans+="X";
        else ans+="Y";
    }
    if (n==1)
    {
        return s;
    }
    for (char c:s)
    {
        if (c!=ans[0]) rest+=c;
    }
    for (int i=2;i<=n-1;i++)
    {
        ret=press(ans+rest[1]+ans+rest[2]+rest[0]+ans+rest[2]+rest[1]+ans+rest[2]+rest[2]);
        if (ret==i-1) ans+=rest[0];
        else if (ret==i) ans+=rest[1];
        else ans+=rest[2];
    }
    for (int i=0;i<3;i++)
    {
        ret=press(ans+rest[i]);
        if (ret==n) return ans+rest[i];
    }
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...