#include using namespace std; using pii=pair; using tii=tuple; using qii=tuple; 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 inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a inline bool chmin_ref(T &a,const T &b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax_ref(T &a,const T &b){ if(a(now-start).count(); return ms; } int get_ms_all_program(){ auto now=chrono::steady_clock::now(); int ms=chrono::duration_cast(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 T get_random_element(const vector &v){ assert(!v.empty()); return v[rand_int(len(v))]; } template void add(vector &a,vector b){ for(auto i:b) a.push_back(i); } template T binary_search(auto f,T ok,T ng){ while(1 D; array,T> Z; array 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,array,array> query(int t,const array &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 s; rep(i,N){ s[i]=min(R[i],sqrt(R[i])*pow(1.05,P[i])*D[i]*Z[turn][i]); if(0> money; array 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 p,r; p.fill(0); r.fill(0); array sold; sold.fill(0); rep(turn,T){ array 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{ while(true){ bool fin=true; rep(i,N){ auto f=[&](int now){ return pow(r[i]+now-1,0.84)<=pow(r[i]+now-1,0.5)*pow(1.05,p[i]); }; if(f(l[i]+1)&&0<=money-B){ l[i]++; money-=B; fin=false; } } if(fin) break; } } 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 << ' ' << Timer::get_ms() << '\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); }