結果

問題 No.1935 Water Simulation
ユーザー yuyu_5510yuyu_5510
提出日時 2022-05-13 23:51:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,127 bytes
コンパイル時間 1,687 ms
コンパイル使用メモリ 175,396 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 10:04:21
合計ジャッジ時間 3,166 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>


using namespace std;
using ll = unsigned long long;

int main(){
    vector<ll> v(4);
    vector<ll> h(4,0);
    for(int i = 0;i < 4;++i){
        cin >> v[i];
    }
    h[0] = 1LL;
    h[1] = 10000LL;
    h[2] = 100000000LL;
    h[3] = 1000000000000LL;
    ll n;
    cin >> n;
    ll cnt = 0;
    vector<ll> mizu(4);
    ll now = 0;
    std::map<pair<ll, ll>,ll> pl;
    mizu[0] = v[0];
    pl[make_pair(v[0], 0)] = 0;
    bool first = false;
    while(n > 0){
        ++cnt;
        --n;
        ll ryo = min(mizu[now], v[(now+1)%4]-mizu[(now+1)%4]);
        mizu[now] -= ryo;
        mizu[(now+1)%4] += ryo;
        ll nxt = mizu[0]*h[0] + mizu[1]*h[1] + mizu[2]*h[2] + mizu[3]*h[3];
        now += 1;
        now %= 4;
        if(pl.count(make_pair(nxt, now)) >= 1 && first == false){
            ll pre = pl[make_pair(nxt, now)];
            ll kaisu = cnt - pre;
            ll tmp = n/kaisu;
            n = n-(kaisu*tmp);
            first = true;
        }
        pl[make_pair(nxt, now)] = cnt;
    }

    for(int i = 0;i < 4;++i){
        cout << mizu[i] << ' ';
    }
    cout << endl;


}
0