Submission #1174116
Source Code Expand
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
#ifdef _WIN32
#include <Windows.h>
#else
#include <sys/time.h>
#endif
class TicToc
{
private:
double getCurrTime(){
#ifdef _WIN32
return GetTickCount() * 1e-3;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec * 1e-6;
#endif
}
double startTime;
public:
void tic(){
startTime = getCurrTime();
}
double toc(){
return getCurrTime() - startTime;
}
};
unsigned xor128(){
static unsigned x=123456789,y=362436069,z=521288629,w=88675123;
unsigned t;
t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
bool getTankSet(int d, const vector<int>& amount, bitset<32>& ans)
{
int n = amount.size();
for(int i=0; i<(1<<n); ++i){
bitset<32> bs(i);
int sum = 0;
for(int j=0; j<n; ++j){
if(bs[j]){
if(amount[j] == 0){
sum = 0;
break;
}
sum += amount[j];
}
}
if(sum == d){
ans = bs;
return true;
}
}
return false;
}
void solve(int d, int t, const vector<int>& capacity, const vector<int>& amount)
{
int n = capacity.size();
const int dMin = 30;
const int capacityMin = 4;
if(dMin <= d){
bitset<32> bs;
if(getTankSet(d, amount, bs)){
cout << "sell " << bs.count();
for(int i=0; i<n; ++i){
if(bs[i])
cout << ' ' << (i + 1);
}
cout << endl;
return;
}
if(t > 1){
for(int i=0; i<n; ++i){
vector<int> amount2 = amount;
amount2[i] = capacity[i];
bitset<32> bs;
if(getTankSet(d, amount2, bs)){
cout << "fill " << (i + 1) << endl;
return;
}
}
for(int i=0; i<n; ++i){
for(int j=0; j<n; ++j){
if(i == j)
continue;
vector<int> amount2 = amount;
int move = min(amount2[i], capacity[j] - amount2[j]);
amount2[i] -= move;
amount2[j] += move;
bitset<32> bs;
if(getTankSet(d, amount2, bs)){
cout << "move " << (i + 1) << ' ' << (j + 1) << endl;
return;
}
}
}
if(t > 2){
for(int i=0; i<n; ++i){
for(int j=0; j<i; ++j){
vector<int> amount2 = amount;
amount2[i] = capacity[i];
amount2[j] = capacity[j];
bitset<32> bs;
if(getTankSet(d, amount2, bs)){
cout << "fill " << (i + 1) << endl;
return;
}
}
}
}
}
}
int index = -1;
int maxIncrement = 0;
for(int i=0; i<n; ++i){
if(capacityMin <= capacity[i]){
int increment = capacity[i] - amount[i];
if(maxIncrement < increment){
maxIncrement = increment;
index = i;
}
}
}
if(index != -1){
cout << "fill " << (index + 1) << endl;
return;
}
index = min_element(capacity.begin(), capacity.end()) - capacity.begin();
if(capacity[index] < capacityMin){
cout << "change " << (index + 1) << endl;
return;
}
cout << "pass" << endl;
}
int main()
{
const int n = 8;
const int maxTurn = 1000;
for(int turn=0; turn<maxTurn; ++turn){
int d, t;
cin >> d >> t;
vector<int> capacity(n), amount(n);
for(int i=0; i<n; ++i)
cin >> capacity[i];
for(int i=0; i<n; ++i)
cin >> amount[i];
solve(d, t, capacity, amount);
}
}
Submission Info
Submission Time |
|
Task |
A - 石油王Xの憂鬱 |
User |
mamekin |
Language |
C++14 (GCC 5.4.1) |
Score |
7308922 |
Code Size |
4724 Byte |
Status |
AC |
Exec Time |
93 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 |
140515 / 417500 |
139235 / 417500 |
155882 / 417500 |
151921 / 417500 |
144502 / 417500 |
148160 / 417500 |
154371 / 417500 |
145936 / 417500 |
148225 / 417500 |
152848 / 417500 |
153714 / 417500 |
144976 / 417500 |
148208 / 417500 |
151711 / 417500 |
144637 / 417500 |
144167 / 417500 |
135031 / 417500 |
138323 / 417500 |
129815 / 417500 |
152481 / 417500 |
156767 / 417500 |
151926 / 417500 |
132663 / 417500 |
150259 / 417500 |
146925 / 417500 |
146418 / 417500 |
135558 / 417500 |
156133 / 417500 |
152036 / 417500 |
148093 / 417500 |
153402 / 417500 |
142733 / 417500 |
136641 / 417500 |
152776 / 417500 |
151005 / 417500 |
145183 / 417500 |
141212 / 417500 |
149742 / 417500 |
137371 / 417500 |
142984 / 417500 |
144113 / 417500 |
151314 / 417500 |
150501 / 417500 |
146833 / 417500 |
140819 / 417500 |
144523 / 417500 |
145502 / 417500 |
145646 / 417500 |
144073 / 417500 |
141113 / 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 |
84 ms |
724 KB |
subtask_01_02.txt |
AC |
79 ms |
720 KB |
subtask_01_03.txt |
AC |
79 ms |
704 KB |
subtask_01_04.txt |
AC |
90 ms |
716 KB |
subtask_01_05.txt |
AC |
89 ms |
592 KB |
subtask_01_06.txt |
AC |
74 ms |
716 KB |
subtask_01_07.txt |
AC |
77 ms |
716 KB |
subtask_01_08.txt |
AC |
79 ms |
716 KB |
subtask_01_09.txt |
AC |
85 ms |
720 KB |
subtask_01_10.txt |
AC |
75 ms |
720 KB |
subtask_01_11.txt |
AC |
90 ms |
720 KB |
subtask_01_12.txt |
AC |
83 ms |
720 KB |
subtask_01_13.txt |
AC |
82 ms |
720 KB |
subtask_01_14.txt |
AC |
83 ms |
720 KB |
subtask_01_15.txt |
AC |
67 ms |
720 KB |
subtask_01_16.txt |
AC |
79 ms |
716 KB |
subtask_01_17.txt |
AC |
85 ms |
716 KB |
subtask_01_18.txt |
AC |
78 ms |
720 KB |
subtask_01_19.txt |
AC |
76 ms |
596 KB |
subtask_01_20.txt |
AC |
73 ms |
592 KB |
subtask_01_21.txt |
AC |
77 ms |
720 KB |
subtask_01_22.txt |
AC |
75 ms |
716 KB |
subtask_01_23.txt |
AC |
78 ms |
720 KB |
subtask_01_24.txt |
AC |
83 ms |
720 KB |
subtask_01_25.txt |
AC |
77 ms |
724 KB |
subtask_01_26.txt |
AC |
78 ms |
716 KB |
subtask_01_27.txt |
AC |
76 ms |
724 KB |
subtask_01_28.txt |
AC |
93 ms |
692 KB |
subtask_01_29.txt |
AC |
86 ms |
720 KB |
subtask_01_30.txt |
AC |
82 ms |
720 KB |
subtask_01_31.txt |
AC |
88 ms |
720 KB |
subtask_01_32.txt |
AC |
76 ms |
720 KB |
subtask_01_33.txt |
AC |
90 ms |
720 KB |
subtask_01_34.txt |
AC |
78 ms |
696 KB |
subtask_01_35.txt |
AC |
85 ms |
716 KB |
subtask_01_36.txt |
AC |
74 ms |
704 KB |
subtask_01_37.txt |
AC |
75 ms |
652 KB |
subtask_01_38.txt |
AC |
75 ms |
720 KB |
subtask_01_39.txt |
AC |
80 ms |
696 KB |
subtask_01_40.txt |
AC |
82 ms |
720 KB |
subtask_01_41.txt |
AC |
79 ms |
720 KB |
subtask_01_42.txt |
AC |
74 ms |
720 KB |
subtask_01_43.txt |
AC |
85 ms |
724 KB |
subtask_01_44.txt |
AC |
73 ms |
588 KB |
subtask_01_45.txt |
AC |
76 ms |
720 KB |
subtask_01_46.txt |
AC |
77 ms |
720 KB |
subtask_01_47.txt |
AC |
72 ms |
720 KB |
subtask_01_48.txt |
AC |
73 ms |
592 KB |
subtask_01_49.txt |
AC |
69 ms |
720 KB |
subtask_01_50.txt |
AC |
71 ms |
720 KB |