Submission #1174851
Source Code Expand
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))
using namespace std;
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
class Timer{
private:
chrono::high_resolution_clock::time_point start_time;
chrono::high_resolution_clock::time_point elapsed;
public:
Timer(){}
void start() { start_time = chrono::system_clock::now();}
double get_elapsed(){
elapsed = chrono::system_clock::now();
return chrono::duration_cast<std::chrono::seconds>(elapsed-start_time).count();
}
};
mt19937 mt;
uniform_real_distribution<double> rnd(0.0,1.0);
// Problem Specific Parameter:
const int MAX_TURN=1000;
int rest=MAX_TURN;
int D,T;
vector<int> C,A;
const int CMAX=80;
vector<int> cap[CMAX+1];
vector<int> con[CMAX+1];
void Input(){
cin >> D >> T;
for(auto &elem:C) cin >> elem;
for(auto &elem:A) cin >> elem;
rest--;
}
void Check(){
rep(i,CMAX+1) cap[i].clear(),con[i].clear();
rep(mask,1<<8){
int sum=0;
rep(i,8) if(mask&(1<<i)) sum+=C[i];
cap[sum].emplace_back(mask);
}
rep(mask,1<<8){
int sum=0;
rep(i,8) if(mask&(1<<i)) sum+=A[i];
con[sum].emplace_back(mask);
}
}
bool Fill(){
int cmax=0,idx=-1,cnt=0;
rep(i,8) if(A[i]==0) cnt++;
rep(i,8) if(A[i]==0 and chmax(cmax,C[i])) idx=i+1;
if(cnt>=3 or cmax>=5){
cout << "fill " << idx << endl;
return true;
}
return false;
}
bool Sell(){
if(con[D].empty()) return false;
const int mask=con[D][0];
vector<int> ans;
rep(i,8) if(mask&(1<<i)) ans.emplace_back(i+1);
cout << "sell" << " " << int(ans.size());
for(const auto &elem:ans) cout << " " << elem;
cout << endl;
return true;
}
const int threshold=25;
void Action(int rest){
const int total=accumulate(begin(C),end(C),0);
if(rest<10 and Sell()) return;
if(rest>=10 and total<40){
const int idx=min_element(begin(C),end(C))-begin(C)+1;
cout << "change " << idx << endl;
return;
}
if(Fill()) return;
if(D>threshold and Sell()) return;
if(D>threshold+5 and !cap[D].empty()){
int need=8,tar=-1;
for(const auto &mask:cap[D]){
int cnt=0;
rep(i,8) if((mask&(1<<i)) and A[i]==0) cnt++;
if(chmin(need,cnt)) tar=mask;
}
if(need+1<=T and T<=rest){
rep(i,8){
if((tar&(1<<i)) and A[i]==0){
const int idx=i+1;
cout << "fill " << idx << endl;
Input();
}
}
}
Check();
if(Sell()) return;
}
cout << "pass" << endl;
return;
}
int main(void){
C=A=vector<int>(8);
while(rest){
Input();
Check();
Action(rest);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 石油王Xの憂鬱 |
User |
Hec |
Language |
C++14 (GCC 5.4.1) |
Score |
5903561 |
Code Size |
3637 Byte |
Status |
AC |
Exec Time |
59 ms |
Memory |
724 KB |
Judge Result
Set Name |
test_01 |
test_02 |
test_03 |
test_04 |
test_05 |
test_06 |
test_07 |
test_08 |
test_09 |
test_10 |
test_11 |
test_12 |
test_13 |
test_14 |
test_15 |
test_16 |
test_17 |
test_18 |
test_19 |
test_20 |
test_21 |
test_22 |
test_23 |
test_24 |
test_25 |
test_26 |
test_27 |
test_28 |
test_29 |
test_30 |
test_31 |
test_32 |
test_33 |
test_34 |
test_35 |
test_36 |
test_37 |
test_38 |
test_39 |
test_40 |
test_41 |
test_42 |
test_43 |
test_44 |
test_45 |
test_46 |
test_47 |
test_48 |
test_49 |
test_50 |
Score / Max Score |
114346 / 417500 |
126650 / 417500 |
120234 / 417500 |
118815 / 417500 |
113292 / 417500 |
121898 / 417500 |
132951 / 417500 |
123820 / 417500 |
128125 / 417500 |
125667 / 417500 |
127103 / 417500 |
115208 / 417500 |
120826 / 417500 |
119357 / 417500 |
116406 / 417500 |
123178 / 417500 |
111097 / 417500 |
106662 / 417500 |
120234 / 417500 |
118426 / 417500 |
132063 / 417500 |
123602 / 417500 |
105713 / 417500 |
105394 / 417500 |
114264 / 417500 |
114326 / 417500 |
117324 / 417500 |
114050 / 417500 |
123824 / 417500 |
113509 / 417500 |
120877 / 417500 |
114011 / 417500 |
117848 / 417500 |
120127 / 417500 |
112426 / 417500 |
123311 / 417500 |
113517 / 417500 |
122709 / 417500 |
110927 / 417500 |
109792 / 417500 |
117649 / 417500 |
114717 / 417500 |
117721 / 417500 |
117940 / 417500 |
117452 / 417500 |
120760 / 417500 |
121089 / 417500 |
111592 / 417500 |
116043 / 417500 |
114689 / 417500 |
Status |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set Name |
Test Cases |
test_01 |
subtask_01_01.txt |
test_02 |
subtask_01_02.txt |
test_03 |
subtask_01_03.txt |
test_04 |
subtask_01_04.txt |
test_05 |
subtask_01_05.txt |
test_06 |
subtask_01_06.txt |
test_07 |
subtask_01_07.txt |
test_08 |
subtask_01_08.txt |
test_09 |
subtask_01_09.txt |
test_10 |
subtask_01_10.txt |
test_11 |
subtask_01_11.txt |
test_12 |
subtask_01_12.txt |
test_13 |
subtask_01_13.txt |
test_14 |
subtask_01_14.txt |
test_15 |
subtask_01_15.txt |
test_16 |
subtask_01_16.txt |
test_17 |
subtask_01_17.txt |
test_18 |
subtask_01_18.txt |
test_19 |
subtask_01_19.txt |
test_20 |
subtask_01_20.txt |
test_21 |
subtask_01_21.txt |
test_22 |
subtask_01_22.txt |
test_23 |
subtask_01_23.txt |
test_24 |
subtask_01_24.txt |
test_25 |
subtask_01_25.txt |
test_26 |
subtask_01_26.txt |
test_27 |
subtask_01_27.txt |
test_28 |
subtask_01_28.txt |
test_29 |
subtask_01_29.txt |
test_30 |
subtask_01_30.txt |
test_31 |
subtask_01_31.txt |
test_32 |
subtask_01_32.txt |
test_33 |
subtask_01_33.txt |
test_34 |
subtask_01_34.txt |
test_35 |
subtask_01_35.txt |
test_36 |
subtask_01_36.txt |
test_37 |
subtask_01_37.txt |
test_38 |
subtask_01_38.txt |
test_39 |
subtask_01_39.txt |
test_40 |
subtask_01_40.txt |
test_41 |
subtask_01_41.txt |
test_42 |
subtask_01_42.txt |
test_43 |
subtask_01_43.txt |
test_44 |
subtask_01_44.txt |
test_45 |
subtask_01_45.txt |
test_46 |
subtask_01_46.txt |
test_47 |
subtask_01_47.txt |
test_48 |
subtask_01_48.txt |
test_49 |
subtask_01_49.txt |
test_50 |
subtask_01_50.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask_01_01.txt |
AC |
57 ms |
720 KB |
subtask_01_02.txt |
AC |
56 ms |
720 KB |
subtask_01_03.txt |
AC |
58 ms |
720 KB |
subtask_01_04.txt |
AC |
59 ms |
720 KB |
subtask_01_05.txt |
AC |
58 ms |
720 KB |
subtask_01_06.txt |
AC |
58 ms |
720 KB |
subtask_01_07.txt |
AC |
58 ms |
712 KB |
subtask_01_08.txt |
AC |
55 ms |
720 KB |
subtask_01_09.txt |
AC |
58 ms |
716 KB |
subtask_01_10.txt |
AC |
58 ms |
720 KB |
subtask_01_11.txt |
AC |
58 ms |
724 KB |
subtask_01_12.txt |
AC |
59 ms |
592 KB |
subtask_01_13.txt |
AC |
59 ms |
724 KB |
subtask_01_14.txt |
AC |
57 ms |
720 KB |
subtask_01_15.txt |
AC |
58 ms |
668 KB |
subtask_01_16.txt |
AC |
55 ms |
664 KB |
subtask_01_17.txt |
AC |
57 ms |
716 KB |
subtask_01_18.txt |
AC |
57 ms |
720 KB |
subtask_01_19.txt |
AC |
57 ms |
720 KB |
subtask_01_20.txt |
AC |
58 ms |
716 KB |
subtask_01_21.txt |
AC |
58 ms |
592 KB |
subtask_01_22.txt |
AC |
57 ms |
720 KB |
subtask_01_23.txt |
AC |
57 ms |
724 KB |
subtask_01_24.txt |
AC |
54 ms |
672 KB |
subtask_01_25.txt |
AC |
57 ms |
720 KB |
subtask_01_26.txt |
AC |
57 ms |
720 KB |
subtask_01_27.txt |
AC |
59 ms |
720 KB |
subtask_01_28.txt |
AC |
57 ms |
720 KB |
subtask_01_29.txt |
AC |
58 ms |
720 KB |
subtask_01_30.txt |
AC |
56 ms |
720 KB |
subtask_01_31.txt |
AC |
56 ms |
720 KB |
subtask_01_32.txt |
AC |
57 ms |
720 KB |
subtask_01_33.txt |
AC |
58 ms |
720 KB |
subtask_01_34.txt |
AC |
56 ms |
716 KB |
subtask_01_35.txt |
AC |
59 ms |
716 KB |
subtask_01_36.txt |
AC |
59 ms |
720 KB |
subtask_01_37.txt |
AC |
57 ms |
720 KB |
subtask_01_38.txt |
AC |
58 ms |
720 KB |
subtask_01_39.txt |
AC |
54 ms |
720 KB |
subtask_01_40.txt |
AC |
57 ms |
720 KB |
subtask_01_41.txt |
AC |
56 ms |
716 KB |
subtask_01_42.txt |
AC |
58 ms |
720 KB |
subtask_01_43.txt |
AC |
57 ms |
724 KB |
subtask_01_44.txt |
AC |
57 ms |
720 KB |
subtask_01_45.txt |
AC |
58 ms |
720 KB |
subtask_01_46.txt |
AC |
59 ms |
720 KB |
subtask_01_47.txt |
AC |
54 ms |
720 KB |
subtask_01_48.txt |
AC |
58 ms |
720 KB |
subtask_01_49.txt |
AC |
59 ms |
716 KB |
subtask_01_50.txt |
AC |
58 ms |
720 KB |