제출 #622721

#제출 시각아이디문제언어결과실행 시간메모리
622721PanTkd콤보 (IOI18_combo)C++14
100 / 100
31 ms568 KiB
//
//  main.cpp
//
//  Created by Panagiotis Chadjicostas on
//  Copyright © Panagiotis Hadjicostas. All rights reserved.
//
#include "combo.h"
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
#define fo(i,a,b) for(int i = a; i<=b; i++)
#define f(i,b) for(int i=0;i<b;i++)
#define F first
#define S second
#define sz size
#define ls s,m,idx<<1
#define rs m+1,e,idx<<1|1
const ll MOD=ll(1e9)+7;
const ll MAXN=2*ll(1e6);
void checker(){
    ll n=rand()%20+2;
    vi a(n,ll());
    for(ll i=0;i<n;i++){
        a[i]=rand()%20+2;
    }
    for(ll b=0;b<(1<<n);b++){
        vi on,off;
        for(ll i=0;i<n;i++){
            if(i&(1<<i)){
                on.push_back(i);
            }
            else{
                off.push_back(i);
            }
        }
    }
}
///////////////////////////////////////////////////////////////////////
int press(string s);
string guess_sequence(int N){
    char ch[4]={'A','B','X','Y'};
 
    // gia na vro to arxiko
    ll idx=3;
    if(press("AB"))idx = (press("A")==1)^1;
    else (idx = 2 + (press("Y")));
    
    swap(ch[0],ch[idx]);
 
    string s="";
    s+=ch[0];
  
  	// meta
    if(N==1)return s;
    for(ll i=2;i<=N-1;i++){
 
        string temp= s;
        temp+=ch[1];
        temp+=s;
        temp+=ch[2];
        temp+=ch[1];
        temp+=s;
        temp+=ch[2];
        temp+=ch[2];
        temp+=s;
        temp+=ch[2];
        temp+=ch[3];
 
        ll ans=press(temp);
 
        if(ans==s.size()){
            s+=ch[3];
        }
        else if(ans==s.size()+2){
            s+=ch[2];
        }
        else
            s+=ch[1];
    }
 
    for(ll i=1;i<=2;i++){
        string temp=s;
        temp+=ch[i];
        if(press(temp)==N)
            return temp;
 
    }
    //cout<<1/0<<endl;
    s+=ch[3];
  	return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:92:15: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |         if(ans==s.size()){
      |            ~~~^~~~~~~~~~
combo.cpp:95:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |         else if(ans==s.size()+2){
      |                 ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...