結果

問題 No.1935 Water Simulation
ユーザー 遭難者遭難者
提出日時 2022-05-16 10:13:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 4,859 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 133,216 KB
実行使用メモリ 814,592 KB
最終ジャッジ日時 2023-10-12 02:14:24
合計ジャッジ時間 5,782 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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()
vector<vector<int>> a1(60, vector<int>(101 * 101 * 101));
vector<vector<int>> a2(60, vector<int>(101 * 101 * 101));
vector<vector<int>> a3(60, vector<int>(101 * 101 * 101));
vector<vector<int>> a4(60, vector<int>(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