Submission #4424095


Source Code Expand

Copy
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <fstream>

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double,int> pdi;
typedef pair<long double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const long double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

//debug
#define DEBUG

#define DUMPOUT cout

#ifdef DEBUG
#define dump(...) DUMPOUT<<#__VA_ARGS__<<" :["<<__FUNCTION__<<":"<<__LINE__<<"]"<<endl; DUMPOUT<<"    "; dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif

void dump_func() {DUMPOUT << endl;};

template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) DUMPOUT << " ";
    else DUMPOUT << ", ";
    dump_func(std::move(tail)...);
}

//ostream
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
    os << "["; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "]";
    return os;
}

template<typename T, typename U> ostream& operator << (ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}

template<typename T, typename U> ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "[";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")"; itr++;  if(itr != map_var.end()) os << ", "; itr--;
    }
    os << "]";
    return os;
}

template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {
    os << "[";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr; ++itr; if(itr != set_var.end()) os << ", "; itr--;
    }
    os << "]";
    return os;
}



auto start = chrono::system_clock::now();

inline bool check_time() {
    auto end = chrono::system_clock::now();
    auto dur = end - start;
    auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
    if (msec >= 28000) return false;
    return true;
}
/*
inline bool check_time1() {
    auto end = chrono::system_clock::now();
    auto dur = end - start;
    auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
    if (msec >= 10000) return false;
    return true;
}

inline bool check_time2() {
    auto end = chrono::system_clock::now();
    auto dur = end - start;
    auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
    if (msec >= 20000) return false;
    return true;
}
*/

inline void now_time() {
  auto end = chrono::system_clock::now();
  auto dur = end - start;
  auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  cout << "time : " << msec << " msec"<< endl;
}

unsigned long seed128[4]; //x,y,z,wとして利用
inline void seed(unsigned int s){
    for(int i=1; i<=4; i++){
        seed128[i-1] = s = 1812433253U * (s^(s>>30)) + i;
    }
}
inline unsigned long Xor128(){
  unsigned long t;
  t=(seed128[0]^(seed128[0]<<11));
  seed128[0]=seed128[1];
  seed128[1]=seed128[2];
  seed128[2]=seed128[3];
  return seed128[3]=(seed128[3]^(seed128[3]>>19))^(t^(t>>8));
}
//---------------------------------global-----------------------------
int D, T;
const int n = 8;
vector<int> C(8), A(8);
vector<int> cnt(11, 0);
//---------------------------------global-----------------------------

void read() {
  cin >> D >> T;
  rep2(i, 1, 11) cnt[i] = 0;
  rep(i, n) {
    cin >> C[i];
    cnt[C[i]]++;
  }
  rep(i, n) cin >> A[i];
}

void fill(int x) {
  x++;
  cout << "fill " <<  x << endl;
}

vector<int> search() {
  int mn_cnt = 10;
  vector<int> com;
  rep(i, 1<<8) {
    int cnt_use = 0;
    int sumC = 0;
    vector<int> tmp;
    rep(j, 8) {
      if (i>>j & 1) {
        sumC += C[j];
        tmp.push_back(j);
        cnt_use++;
      }
    }
    if (sumC == D) {
      if (cnt_use < mn_cnt) {
        mn_cnt = cnt_use;
        com = tmp;
      }
    }
  }
  return com;
}
vector<int> search_ans() {
  vector<int> ans;
  int mn_cnt = 10;
  rep(i, 1<<8) {
    int sumC = 0;
    int cnt_use = 0;
    vector<int> tmp;
    rep(j, 8) {
      if (i>>j & 1) {
        if (A[j] == 0) continue;
        sumC += A[j];
        tmp.push_back(j);
        cnt_use++;
      }
    }
    if (sumC == D) {
      if (cnt_use < mn_cnt) {
        ans = tmp;
        cnt_use = mn_cnt;
      }
    }
  }
  return ans;
}

void sell(vector<int> &ans) {
  cout << "sell " << ans.size() << " ";
  rep(i, ans.size()) cout << ans[i] + 1 << " ";
  cout << endl;
}

void change(int x) {
  x++;
  cout << "change " << x << endl;
}

bool all_fill() {
  rep(i, n) {
    if (A[i] != C[i]) return false;
  }
  return true;
}

bool check_3to10() {
  rep2(i, 3, 11) {
    if (cnt[i] == 0 || cnt[i] >= 2) return false;
  }
  if (cnt[1] >= 1 || cnt[2] >= 1) return false;
  return true;
}

void solve() {
  int seednum = 37;
  seed(seednum);
  int cnt_q = 0;
  while(true) {
    cnt_q++;
    if (cnt_q == 1001) return;
    read();
    vector<int> com = search();
    //cerr << com.size() << endl;
    if (com.size() >=  1) {
      vector<int> ans = search_ans();
      if (ans.size() != 0) {
        sell(ans);
      }
      else {
        for (auto i : com) {
          if (A[i] != C[i]) {
            fill(i);
            break;
          }
        }
      }
    }
    else {
      int change_idx = Xor128() % 8;
      change(change_idx);
    }
  }
}

signed main() {
  solve();
}

Submission Info

Submission Time
Task A - 石油王Xの憂鬱
User roto_37
Language C++14 (GCC 5.4.1)
Score 4273037
Code Size 7296 Byte
Status
Exec Time 127 ms
Memory 724 KB

Judge Result

Set Name Score / Max Score Test Cases
test_01 85203 / 417500 subtask_01_01.txt
test_02 84030 / 417500 subtask_01_02.txt
test_03 87359 / 417500 subtask_01_03.txt
test_04 86740 / 417500 subtask_01_04.txt
test_05 85400 / 417500 subtask_01_05.txt
test_06 97699 / 417500 subtask_01_06.txt
test_07 91601 / 417500 subtask_01_07.txt
test_08 91184 / 417500 subtask_01_08.txt
test_09 87904 / 417500 subtask_01_09.txt
test_10 97818 / 417500 subtask_01_10.txt
test_11 84442 / 417500 subtask_01_11.txt
test_12 83105 / 417500 subtask_01_12.txt
test_13 92553 / 417500 subtask_01_13.txt
test_14 84785 / 417500 subtask_01_14.txt
test_15 83264 / 417500 subtask_01_15.txt
test_16 86582 / 417500 subtask_01_16.txt
test_17 79640 / 417500 subtask_01_17.txt
test_18 71622 / 417500 subtask_01_18.txt
test_19 83191 / 417500 subtask_01_19.txt
test_20 84265 / 417500 subtask_01_20.txt
test_21 82772 / 417500 subtask_01_21.txt
test_22 77566 / 417500 subtask_01_22.txt
test_23 81260 / 417500 subtask_01_23.txt
test_24 83886 / 417500 subtask_01_24.txt
test_25 84631 / 417500 subtask_01_25.txt
test_26 91827 / 417500 subtask_01_26.txt
test_27 84085 / 417500 subtask_01_27.txt
test_28 84023 / 417500 subtask_01_28.txt
test_29 85682 / 417500 subtask_01_29.txt
test_30 83029 / 417500 subtask_01_30.txt
test_31 90393 / 417500 subtask_01_31.txt
test_32 88330 / 417500 subtask_01_32.txt
test_33 75231 / 417500 subtask_01_33.txt
test_34 81969 / 417500 subtask_01_34.txt
test_35 86202 / 417500 subtask_01_35.txt
test_36 90049 / 417500 subtask_01_36.txt
test_37 93249 / 417500 subtask_01_37.txt
test_38 88688 / 417500 subtask_01_38.txt
test_39 75721 / 417500 subtask_01_39.txt
test_40 78686 / 417500 subtask_01_40.txt
test_41 88457 / 417500 subtask_01_41.txt
test_42 89446 / 417500 subtask_01_42.txt
test_43 92441 / 417500 subtask_01_43.txt
test_44 82470 / 417500 subtask_01_44.txt
test_45 89647 / 417500 subtask_01_45.txt
test_46 85773 / 417500 subtask_01_46.txt
test_47 81960 / 417500 subtask_01_47.txt
test_48 79604 / 417500 subtask_01_48.txt
test_49 85266 / 417500 subtask_01_49.txt
test_50 82307 / 417500 subtask_01_50.txt
Case Name Status Exec Time Memory
subtask_01_01.txt 123 ms 724 KB
subtask_01_02.txt 124 ms 720 KB
subtask_01_03.txt 127 ms 720 KB
subtask_01_04.txt 125 ms 720 KB
subtask_01_05.txt 124 ms 724 KB
subtask_01_06.txt 125 ms 724 KB
subtask_01_07.txt 123 ms 724 KB
subtask_01_08.txt 120 ms 720 KB
subtask_01_09.txt 118 ms 696 KB
subtask_01_10.txt 123 ms 724 KB
subtask_01_11.txt 123 ms 724 KB
subtask_01_12.txt 124 ms 724 KB
subtask_01_13.txt 123 ms 720 KB
subtask_01_14.txt 124 ms 720 KB
subtask_01_15.txt 125 ms 720 KB
subtask_01_16.txt 121 ms 724 KB
subtask_01_17.txt 123 ms 720 KB
subtask_01_18.txt 122 ms 724 KB
subtask_01_19.txt 124 ms 592 KB
subtask_01_20.txt 124 ms 724 KB
subtask_01_21.txt 122 ms 724 KB
subtask_01_22.txt 123 ms 724 KB
subtask_01_23.txt 123 ms 720 KB
subtask_01_24.txt 125 ms 720 KB
subtask_01_25.txt 124 ms 720 KB
subtask_01_26.txt 126 ms 724 KB
subtask_01_27.txt 125 ms 724 KB
subtask_01_28.txt 125 ms 724 KB
subtask_01_29.txt 122 ms 596 KB
subtask_01_30.txt 124 ms 720 KB
subtask_01_31.txt 127 ms 724 KB
subtask_01_32.txt 126 ms 724 KB
subtask_01_33.txt 122 ms 724 KB
subtask_01_34.txt 124 ms 596 KB
subtask_01_35.txt 121 ms 724 KB
subtask_01_36.txt 124 ms 720 KB
subtask_01_37.txt 124 ms 724 KB
subtask_01_38.txt 124 ms 724 KB
subtask_01_39.txt 123 ms 724 KB
subtask_01_40.txt 124 ms 724 KB
subtask_01_41.txt 125 ms 720 KB
subtask_01_42.txt 122 ms 724 KB
subtask_01_43.txt 126 ms 588 KB
subtask_01_44.txt 125 ms 696 KB
subtask_01_45.txt 125 ms 724 KB
subtask_01_46.txt 124 ms 596 KB
subtask_01_47.txt 123 ms 596 KB
subtask_01_48.txt 124 ms 720 KB
subtask_01_49.txt 123 ms 596 KB
subtask_01_50.txt 122 ms 720 KB