結果

問題 No.1935 Water Simulation
ユーザー RubikunRubikun
提出日時 2022-05-14 03:12:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,400 bytes
コンパイル時間 2,206 ms
コンパイル使用メモリ 209,424 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-29 14:45:52
合計ジャッジ時間 6,271 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005;
const ll INF=1LL<<60;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<int> V(4);
    for(int i=0;i<4;i++) cin>>V[i];
    ll N;cin>>N;
    map<vector<int>,int> MA;
    vector<int> now(4);now[0]=V[0];
    MA[now]=0;
    int syuu=-1;
    for(int t=4;;t+=4){
        for(int i=0;i<4;i++){
            int x=min(now[i],V[(i+1)%4]-now[(i+1)%4]);
            now[i]-=x;
            now[(i+1)%4]+=x;
        }
        if(MA.count(now)){
            syuu=t-MA[now];
            break;
        }else{
            MA[now]=t;
        }
    }
    
    ll can=N/syuu-2;
    chmax(can,0LL);
    
    for(int i=0;i<4;i++){
        if(i==0) now[i]=V[0];
        else now[i]=0;
    }
    
    for(ll t=0;t<N;t++){
        int x=min(now[t%4],V[(t+1)%4]-now[(t+1)%4]);
        now[t%4]-=x;
        now[(t+1)%4]+=x;
    }
    
    for(int i=0;i<4;i++){
        cout<<now[i]<<" ";
    }
    cout<<endl;
}

0