Submission #1173367


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
struct Action{
    string str;
    vector<int> ints;
};

struct Problem{
    int n,d,t;
    vector<int> cap,now,half;
    vector<vector<int>> can_sell;
    Problem(LL n):n(n),cap(n),now(n),can_sell(81){};
    const int turn= 1000;
    queue<Action> to_do;
    void solve(){
        for(int i=0; i<turn; ++i){
            input();
            if(!to_do.empty()){
                act();
                continue;
            }
            bf(); //タンクの容量いっぱいに入れる場合だけ
            int mask=-1,tt=t;
            for(auto && i: can_sell[d]){
                int t_fill=0;
                for(int b=0; b<8; ++b){
                    if(i&(1<<b) && now[b]!=cap[b]) ++t_fill;
                }
                if(t_fill<tt)mask=i,tt=t_fill;
            }
            if(mask!=-1){ //詰めて売る
                vector<int> to_sell={0};
                for(int b=0; b<8; ++b){
                    if(mask&(1<<b)){
                        if(now[b]!=cap[b])to_do.push({"fill",{b+1}});
                        to_sell[0]++;
                        to_sell.push_back(b+1);
                    }
                }
                to_do.push({"sell",to_sell});
            }else{
                if(t<4)to_do.push({"pass",{}});
                else{
                    int mini=INF,pos=-1;
                    for(int i=0; i<8; ++i){
                        if(cap[i]<mini)mini=cap[i],pos=i;
                    }
                    to_do.push({"change",{pos+1}});
                }
            }
            act();
        }
    }
    void bf(){
        can_sell=vector<vector<int>>(81);
        for(int i=1; i<255; ++i){
            int oil=0;
            for(int b=0; b<8; ++b){
                if(i&(1<<b)) oil+=cap[b];
            }
            can_sell[oil].push_back(i);
        }
    }
    void input(){
        cin >> d >> t;
        for(int i=0; i<n; ++i){
            cin >> cap[i];
        }
        for(int i=0; i<n; ++i){
            cin >> now[i];
        }
    }
    void act(){
        cout << to_do.front().str;
        for(auto i : to_do.front().ints)cout << ' ' <<i;
        cout << endl;
        to_do.pop();
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=8;

    Problem p(n);
    p.solve();
    return 0;
}

Submission Info

Submission Time
Task A - 石油王Xの憂鬱
User Hoi_koro
Language C++14 (Clang 3.8.0)
Score 0
Code Size 2713 Byte
Status CE

Compile Error

./Main.cpp:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
         ^
1 error generated.