結果

問題 No.1935 Water Simulation
ユーザー 遭難者遭難者
提出日時 2022-05-16 10:15:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 4,731 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 130,516 KB
実行使用メモリ 801,696 KB
最終ジャッジ日時 2023-10-12 02:16:47
合計ジャッジ時間 5,810 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
351,268 KB
testcase_01 AC 126 ms
351,324 KB
testcase_02 AC 62 ms
263,960 KB
testcase_03 AC 226 ms
462,620 KB
testcase_04 AC 91 ms
307,724 KB
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 97 ms
493,048 KB
testcase_13 AC 98 ms
492,856 KB
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 97 ms
492,856 KB
testcase_19 MLE -
testcase_20 AC 100 ms
499,072 KB
testcase_21 MLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 AC 98 ms
496,960 KB
testcase_27 MLE -
testcase_28 MLE -
testcase_29 AC 98 ms
492,900 KB
testcase_30 AC 98 ms
492,820 KB
testcase_31 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
using namespace std;
using ll = long long;
//#include <atcoder/all>
// using namespace atcoder;
// using mint = modint;
#define rep(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define print(n) cout << (n) << endl
#define ALL(a) (a).begin(), (a).end()
int a1[60][101 * 101 * 101], a2[60][101 * 101 * 101], a3[60][101 * 101 * 101], a4[60][101 * 101 * 101];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int v1, v2, v3, v4;
    cin >> v1 >> v2 >> v3 >> v4;
    int vv = (v1 + 1) * (v1 + 1), vvv = vv * (v1 + 1);
    for (int i = 0; i <= v1; i++)
    {
        for (int j = 0; j <= v2; j++)
        {
            int s1 = i + j;
            if (s1 > v1)
                break;
            for (int k = 0; k <= v3; k++)
            {
                int s2 = s1 + k;
                if (s2 > v1)
                    break;
                int key = vv * i + v1 * j + k;
                int l = v1 - s2;
                int ii = i, jj = j, kk = k, ll = l;
                jj += ii;
                ii = 0;
                if (jj > v2)
                {
                    ii = jj - v2;
                    jj = v2;
                }
                kk += jj;
                jj = 0;
                if (kk > v3)
                {
                    jj = kk - v3;
                    kk = v3;
                }
                ll += kk;
                kk = 0;
                if (ll > v4)
                {
                    kk = ll - v4;
                    ll = v4;
                }
                ii += ll;
                ll = 0;
                if (ii > v1)
                {
                    ll = ii - v1;
                    ii = v1;
                }
                a1[0][key] = ii;
                a2[0][key] = jj;
                a3[0][key] = kk;
                a4[0][key] = ll;
            }
        }
    }
    for (int idx = 1; idx < 60; idx++)
    {
        for (int i = 0; i <= v1; i++)
        {
            for (int j = 0; j <= v2; j++)
            {
                int s1 = i + j;
                if (s1 > v1)
                    break;
                for (int k = 0; k <= v3; k++)
                {
                    int s2 = s1 + k;
                    if (s2 > v1)
                        break;
                    // int l = v1 - s2;
                    int key1 = vv * i + v1 * j + k;
                    int ii = a1[idx - 1][key1];
                    int jj = a2[idx - 1][key1];
                    int kk = a3[idx - 1][key1];
                    // int ll = a4[idx - 1][key1];
                    int key2 = vv * ii + v1 * jj + kk;
                    int iii = a1[idx - 1][key2];
                    int jjj = a2[idx - 1][key2];
                    int kkk = a3[idx - 1][key2];
                    int lll = a4[idx - 1][key2];
                    a1[idx][key1] = iii;
                    a2[idx][key1] = jjj;
                    a3[idx][key1] = kkk;
                    a4[idx][key1] = lll;
                }
            }
        }
    }
    ll k_;
    cin >> k_;
    ll k1 = k_ >> 2, k2 = k_ & 3;
    int i = v1, j = 0, k = 0, l = 0;
    for (int idx = 0; k1 != 0; idx++)
    {
        if ((k1 & 1) == 1)
        {
            int key = vv * i + v1 * j + k;
            int ii = a1[idx][key];
            int jj = a2[idx][key];
            int kk = a3[idx][key];
            int ll = a4[idx][key];
            i = ii;
            j = jj;
            k = kk;
            l = ll;
        }
        k1 >>= 1;
    }
    if (k2 == 0)
    {
        cout << i << " " << j << " " << k << " " << l << endl;
        return 0;
    }
    j += i;
    i = 0;
    if (j > v2)
    {
        i = j - v2;
        j = v2;
    }
    if (--k2 == 0)
    {
        cout << i << " " << j << " " << k << " " << l << endl;
        return 0;
    }
    k += j;
    j = 0;
    if (k > v3)
    {
        j = k - v3;
        k = v3;
    }
    if (--k2 == 0)
    {
        cout << i << " " << j << " " << k << " " << l << endl;
        return 0;
    }
    l += k;
    k = 0;
    if (l > v4)
    {
        k = l - v4;
        l = v4;
    }
    if (--k2 == 0)
    {
        cout << i << " " << j << " " << k << " " << l << endl;
        return 0;
    }
    i += l;
    l = 0;
    if (i > v1)
    {
        l = i - v1;
        i = v1;
    }
    if (--k2 == 0)
    {
        cout << i << " " << j << " " << k << " " << l << endl;
        return 0;
    }
}
0