結果

問題 No.5018 Let's Make a Best-seller Book
コンテスト
ユーザー FplusFplusF
提出日時 2026-05-08 01:22:43
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 32 ms / 400 ms
コード長 7,315 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,555 ms
コンパイル使用メモリ 339,304 KB
実行使用メモリ 30,308 KB
スコア 90,837
平均クエリ数 52.00
最終ジャッジ日時 2026-05-08 01:22:57
合計ジャッジ時間 9,719 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using tii=tuple<int,int,int>;
using qii=tuple<int,int,int,int>;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
constexpr int INF=1e9;
constexpr ll INF_ll=1e18;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define replr(i,l,r) for (int i=(int)(l);i<(int)(r);i++)
#define all(v) v.begin(),v.end()
#define len(v) ((int)v.size())
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin_ref(T &a,const T &b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax_ref(T &a,const T &b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

namespace Timer{
    chrono::steady_clock::time_point program_start,start;
    void program_start_snap(){
        program_start=start=chrono::steady_clock::now();
    }
    void snap(){
        start=chrono::steady_clock::now();
    }
    int get_ms(){
        auto now=chrono::steady_clock::now();
        int ms=chrono::duration_cast<chrono::milliseconds>(now-start).count();
        return ms;
    }
    int get_ms_all_program(){
        auto now=chrono::steady_clock::now();
        int ms=chrono::duration_cast<chrono::milliseconds>(now-program_start).count();
        return ms;
    }
}

mt19937 mt(0);


uint32_t rand_int(uint32_t r){  //[0,r)
    assert(r!=0);
    return ((uint64_t)mt()*r)>>32;
}
int rand_int(int l,int r){  //[l,r)
    assert(l<r);
    return l+rand_int(r-l);
}
constexpr double one_div_mt_max=1.0/(double)mt19937::max();
double rand_double(){  //[0.0,1.0]
    return mt()*one_div_mt_max;
}
double rand_double(double l,double r){  //[l,r]
    return l+rand_double()*(r-l);
}
template<class T> T get_random_element(const vector<T> &v){
    assert(!v.empty());
    return v[rand_int(len(v))];
}

template<class T> void add(vector<T> &a,vector<T> b){
    for(auto i:b) a.push_back(i);
}

constexpr int T=52,N=10,M=2000000,B=500,C=500000;

namespace Communication{
    
    int money=M;
    
    
    #ifdef LOCAL
    
    int turn=0;
    
    int result=0;
    
    array<double,N> D;
    
    array<array<double,N>,T> Z;
    
    array<int,N> P,R;
    
    
    void init(){
        
        turn=0;
        result=0;
        money=M;
        
        P.fill(0);
        R.fill(0);
        
        rep(i,N){
            D[i]=rand_double(0.5,1.5);
        }
        rep(t,T){
            rep(i,N){
                Z[t][i]=rand_double(0.75,1.25);
            }
        }
    }
    
    #endif
    
    tuple<int,array<int,N>,array<int,N>,array<int,N>> query(int t,const array<int,N> &l,int x=-1){
        
        
        if(t==1){
            
            int sum=0;
            rep(i,N) sum+=l[i];
            
            assert(sum*B<=money);
            
            #ifdef LOCAL
            
            money-=sum*B;
            rep(i,N){
                R[i]+=l[i];
            }
                
            #else
            
            cout << t << ' ';
            rep(i,N) cout << l[i] << ' ';
            cout << '\n';
            cout.flush();
            
            #endif
            
        }else if(t==2){
            
            assert(1<=x&&x<=5);
            
            assert(C*(1<<(x-1))<=money);
            
            #ifdef LOCAL
            
            money-=C*(1<<(x-1));
        
            rep(i,N){
                P[i]+=x;
            }
            
            #else
            
            cout << t << ' ' << x;
            cout << '\n';
            
            cout.flush();
            
            #endif
            
        }else{
            assert(0);
        }
        
        
        
        #ifdef LOCAL
        
        array<int,N> s;
        
        rep(i,N){
            
            s[i]=min<double>(R[i],sqrt(R[i])*pow(1.05,P[i])*D[i]*Z[turn][i]);
            
            if(0<R[i]){
            
                if(3*R[i]<=10*s[i]){
                    P[i]++;
                }
                if(10*s[i]<R[i]){
                    P[i]--;
                }
                
                P[i]=clamp(P[i],-60,60);
            }
            
            
            R[i]-=s[i];
            
            money+=1000*s[i];
            
            result+=s[i];
        }
        
        turn++;
        
        
        return {money,s,P,R};
        
        #else
        
        cin >> money;
        
        array<int,N> s,p,r;
        rep(i,N) cin >> s[i];
        rep(i,N) cin >> p[i];
        rep(i,N) cin >> r[i];
        
        return {money,s,p,r};
        
        #endif
        
    }
};

namespace Solver{
    void solve(){
        
        int money=M;
        
        array<int,N> p,r;
        
        p.fill(0);
        r.fill(0);
        
        array<int,N> sold;
        sold.fill(0);
        
        
        rep(turn,T){
            
            
            array<int,N> l;
            
            l.fill(0);
            
            int t=1,x=-1;
            
            if(T-5<=turn){
                
                l.fill(money/B/N);
                
            }else if(turn%2==1&&C*(1<<2)<=money){
                t=2;
                x=2;
            }else{
            
                rep(i,N){
                    int now=0;
                    while(pow(r[i]+now,0.84)<=pow(r[i]+now,0.5)*pow(1.05,p[i])&&0<=money-B){
                        now++;
                        money-=B;
                    }
                    l[i]=now;
                }
            }
            
            
            auto [new_money,s,new_p,new_r]=Communication::query(t,l,x);
            
            p=new_p;
            r=new_r;
            
            /*cerr << "turn:" << turn << " money:" << money << endl;
            
            cerr << "s:";
            rep(i,N){
                cerr << s[i] << " ";
            }
            cerr << endl;
            
            cerr << "p:";
            rep(i,N){
                cerr << p[i] << " ";
            }
            cerr << endl;
            
            cerr << "r:";
            rep(i,N){
                cerr << r[i] << " ";
            }
            cerr << endl;
            
            cerr << endl;*/
            
            money=new_money;
            
            rep(i,N) sold[i]+=s[i];
        }
        
    }
    
    
    #ifdef LOCAL
    
    void solve_many(){
        
        int loop=1000;
        
        int sum=0;
        
        rep(_,loop){
            
            Communication::init();
            
            solve();
            
            int score=(Communication::result+99)/100;
            
            sum+=score;
        }
        
        cerr << sum << '\n';
        
        exit(0);
    }
    
    #endif
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Timer::program_start_snap();
    
    
    
    #ifdef LOCAL
    
    Solver::solve_many();
    
    #else
    
    int t,n,m;
    cin >> t >> n >> m;
    
    assert(t==T);
    assert(n==N);
    assert(m==M);
    
    #endif
    



    Solver::solve();
    exit(0);
}
0