結果

問題 No.1935 Water Simulation
ユーザー みここ
提出日時 2022-05-13 21:30:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 65,008 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-22 01:02:13
合計ジャッジ時間 1,679 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

ll d[102][102][102][102];

int main()
{
    int v[4];
    for(int i = 0; i < 4; i++)
    {
        cin >> v[i];
    }
    ll n;
    cin >> n;
    int a[4]{0};
    a[0] = v[0];
    int i = 0;
    while(true)
    {
        if(d[a[0]][a[1]][a[2]][a[3]])
        {
            n %= (d[a[0]][a[1]][a[2]][a[3]] - n);
        }
        else
        {
            d[a[0]][a[1]][a[2]][a[3]] = n;
        }
        if(!n) break;
        int k = min(a[i], v[(i + 1) % 4] - a[(i + 1) % 4]);
        a[i] -= k;
        a[(i + 1) % 4] += k;
        i = (i + 1) % 4;
        n--;
    }
    for(int i = 0; i < 4; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}
0