結果

問題 No.5003 物理好きクリッカー
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-09-11 15:03:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,337 ms / 10,000 ms
コード長 5,453 bytes
コンパイル時間 6,358 ms
コンパイル使用メモリ 335,728 KB
実行使用メモリ 24,372 KB
スコア 64,631,560,901
平均クエリ数 10000.00
最終ジャッジ日時 2023-09-11 15:04:49
合計ジャッジ時間 51,018 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,281 ms
23,388 KB
testcase_01 AC 1,288 ms
23,412 KB
testcase_02 AC 1,280 ms
23,424 KB
testcase_03 AC 1,288 ms
23,544 KB
testcase_04 AC 1,308 ms
24,276 KB
testcase_05 AC 1,279 ms
23,820 KB
testcase_06 AC 1,337 ms
23,640 KB
testcase_07 AC 1,286 ms
24,372 KB
testcase_08 AC 1,315 ms
24,228 KB
testcase_09 AC 1,307 ms
24,348 KB
testcase_10 AC 1,298 ms
23,532 KB
testcase_11 AC 1,275 ms
23,856 KB
testcase_12 AC 1,295 ms
23,652 KB
testcase_13 AC 1,281 ms
23,400 KB
testcase_14 AC 1,259 ms
23,628 KB
testcase_15 AC 1,307 ms
23,532 KB
testcase_16 AC 1,289 ms
23,844 KB
testcase_17 AC 1,292 ms
24,024 KB
testcase_18 AC 1,300 ms
24,024 KB
testcase_19 AC 1,272 ms
24,072 KB
testcase_20 AC 1,296 ms
23,976 KB
testcase_21 AC 1,305 ms
23,628 KB
testcase_22 AC 1,283 ms
23,640 KB
testcase_23 AC 1,293 ms
23,628 KB
testcase_24 AC 1,294 ms
23,544 KB
testcase_25 AC 1,292 ms
23,832 KB
testcase_26 AC 1,310 ms
24,036 KB
testcase_27 AC 1,277 ms
23,832 KB
testcase_28 AC 1,280 ms
23,976 KB
testcase_29 AC 1,293 ms
23,388 KB
testcase_30 AC 1,271 ms
23,628 KB
testcase_31 AC 1,305 ms
24,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//諸々include、namespace設定(ACLも使用可能)
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace chrono;
using namespace atcoder;
using ll=unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

//0以上2^32-1以下の整数をランダムに生成(xorshift32)
//seed値を固定しているため、基本結果が上振れたり下振れたりしない
unsigned int randxor(){
    static unsigned int x=42;
    x=x^(x<<13);x=x^(x>>15);x=x^(x<<17);
    return x;
}

//l以上r以下の整数をランダムに生成
int randint(int l,int r){
    return l+randxor()%(r-l+1);
}

//l以上r以下の実数をランダムに生成
double uniform(double l,double r){
    return ((double)randxor()/UINT_MAX)*(r-l)+l;
}

//時間計測(ミリ秒)、秒に直す場合10^6で割ると得られる
auto startTime=system_clock::now();
int getTime(){
    return duration_cast<microseconds>(system_clock::now()-startTime).count();
}

//ゲームをプレイする
const vector<string> behavior={"click","buy","sell","reinforce","enhclick"};
const vector<string> facil={" hand"," lily"," factory"," casino"," grimoire",""};
const vector<int> price={150,2000,30000,600000,10000000};
const vector<int> prod={1,10,120,2000,25000};
int N;
string S;
struct game{
    //評価関数:Nターンclickのみ行った場合のクッキーの枚数
    ll cookie;
    int turn;
    ll clickprod;
    int discount;
    int fever;
    int mag;
    vector<int> pos_number;
    vector<ll> rein;
    queue<int> ans;
    
    game(){
        turn=0;
        cookie=0;
        clickprod=1;
        discount=10;
        fever=0;
        mag=1;
        pos_number={0,0,0,0,0};
        rein={1,1,1,1,1};
    }
    
    void production(){
        rep(i,5){
            cookie+=prod[i]*pos_number[i]*rein[i]*mag;
        }
        discount=10;
        fever--;
        if(S[turn]=='B')cookie=(cookie*101+99)/100;
        else if(S[turn]=='F'){fever=20;mag=7;}
        else if(S[turn]=='S')discount=9;
        if(fever<=0)mag=1;
        turn++;
    }
    
    bool click(){
        cookie+=clickprod*mag;
        ans.push(5);
        production();
        return true;
    }
    
    bool buy(int kinds){
        ll nowprice=price[kinds];
        rep(i,pos_number[kinds]){
            nowprice=(nowprice*6+4)/5;
        }
        if(cookie>=nowprice){
            cookie-=nowprice;
            pos_number[kinds]++;
            production();
            ans.push(6+kinds);
            return true;
        }
        return false;
    }
    
    bool sell(int kinds){
        if(pos_number[kinds]>0){
            ll nowprice=price[kinds];
            pos_number[kinds]--;
            rep(i,pos_number[kinds]){
                nowprice=(nowprice*6+4)/5;
            }
            cookie+=(nowprice+3)/4;
            production();
            ans.push(12+kinds);
            return true;
        }
        return false;
    }
    
    bool reinforce(int kinds){
        if(pos_number[kinds]>0){
            ll nowprice=price[kinds]*10;
            ll cnt=1;
            while(cnt<rein[kinds]){
                nowprice*=10;
                cnt*=2;
            }
            if(cookie>=nowprice){
                rein[kinds]*=2;
                cookie-=nowprice;
                production();
                ans.push(18+kinds);
                return true;
            }
            return false;
        }
        return false;
    }
    
    bool enhclick(){
        ll nowprice=15;
        ll cnt=1;
        while(cnt<clickprod){
            nowprice*=10;
            cnt*=2;
        }
        if(cookie>=nowprice){
            clickprod*=2;
            cookie-=nowprice;
            production();
            ans.push(29);
            return true;
        }
        return false;
    }
    
    ll score(){
        tuple<ll,int,int,int,int> pre={cookie,discount,fever,mag,turn};
        rep(i,min(N-turn,500)){
            cookie+=clickprod*mag;
            production();
        }
        ll ret=cookie;
        tie(cookie,discount,fever,mag,turn)=pre;
        return ret;
    }
    
    void print(){
        while(ans.size()>0){
            int action=ans.front();
            ans.pop();
            cout<<behavior[action/6]<<facil[action%6]<<endl;
            string reac;
            cin>>reac;
            if(reac!="ok"){
                cerr<<reac<<" "<<behavior[action/6]<<facil[action%6]<<endl;
            }
        }
    }
};

//主要部分
int main(){
    cin>>N;
    cin>>S;
    game g;
    rep(i,N){
        game pre=g;
        pre.click();
        ll score=pre.score();
        game now=g;
        if(now.enhclick()){
            if(score<now.score()){
                score=now.score();
                pre=now;
            }
        }
        rep(i,5){
            now=g;
            if(now.buy(i)){
                if(score<now.score()){
                    score=now.score();
                    pre=now;
                }
            }
            now=g;
            if(now.sell(i)){
                if(score<now.score()){
                    score=now.score();
                    pre=now;
                }
            }
            now=g;
            if(now.reinforce(i)){
                if(score<now.score()){
                    score=now.score();
                    pre=now;
                }
            }
        }
        g=pre;
    }
    cerr<<"Score:"<<g.cookie<<endl;
    g.print();
    return 0;
}
0