結果

問題 No.1935 Water Simulation
ユーザー iwaiwaiwaispiwaiwaiwaisp
提出日時 2022-05-13 22:09:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,877 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 169,412 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 10:01:35
合計ジャッジ時間 2,959 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <list> 

using namespace std;

#define reps(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define rep(i, n) reps(i, 0, n)

#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による

#define F first
#define S second

#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
#define coutALL2d(vv) for(const auto& v : vv){for(const auto& e : v){cout << e << " ";}cout << endl;}

#define vi vector<int>
#define vvi vector<vector<int> >
#define vll vector<long long>
#define vvll vector<vector<long long> >

int main(){
    long long n;
    vi v(4,0);
    cin >> v[0] >> v[1] >> v[2] >> v[3] >> n;
    int mn = 101;
    rep(i,4){
        mn = min({v[i],mn});
    }
    int cnt = 0;
    int count = 1;
    vi c(4, 0);
    c[0] = v[0];
    vvi r(4,vi(4));
    int idx = 0;
    int tmp = 0;
    int beftmp = 0;
    while(cnt <= 8){
        if(c[idx] >= v[(idx+1) % 4] - c[(idx+1) % 4]){
            tmp = v[(idx+1) % 4] - c[(idx+1) % 4];
            c[(idx+1) % 4] = v[(idx+1) % 4];
            c[idx] = c[idx] - tmp; 
        }
        else{
            tmp = c[idx];
            c[(idx+1) % 4] = c[(idx+1) % 4] + c[idx];
            c[idx] = 0;
        }
        
        if(beftmp == tmp){
            cnt++;
        }else{
            cnt = 0;
        }
        beftmp = tmp;
        idx = (idx+1)%4;

        if(cnt > 4){
            rep(i,4) r[count%4][i] = c[i];
        }
        if(count == n){
            coutALL(c);
            exit(0);
        }
        count++;
    }
    //coutALL2d(r);
    //cout << r[n%4] << endl;
    coutALL(r[n%4]);
}


0