結果
| 問題 |
No.5003 物理好きクリッカー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-09-11 15:09:44 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,341 ms / 10,000 ms |
| コード長 | 5,313 bytes |
| コンパイル時間 | 6,556 ms |
| コンパイル使用メモリ | 334,888 KB |
| 実行使用メモリ | 24,372 KB |
| スコア | 139,156,437,077 |
| 平均クエリ数 | 10000.00 |
| 最終ジャッジ日時 | 2023-09-11 15:10:37 |
| 合計ジャッジ時間 | 51,641 ms |
|
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
//諸々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,1200)){
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;
cin>>action;
}
}
};
//主要部分
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;
}