結果

問題 No.1935 Water Simulation
ユーザー RubikunRubikun
提出日時 2022-05-13 21:31:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,327 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 210,140 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 09:54:10
合計ジャッジ時間 3,682 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
    N-=can*syuu;
    
    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