結果
問題 | No.1935 Water Simulation |
ユーザー | 遭難者 |
提出日時 | 2022-05-16 10:15:52 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 4,731 bytes |
コンパイル時間 | 2,179 ms |
コンパイル使用メモリ | 132,276 KB |
実行使用メモリ | 800,168 KB |
最終ジャッジ日時 | 2024-09-14 02:04:27 |
合計ジャッジ時間 | 7,799 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
340,544 KB |
testcase_01 | AC | 127 ms
387,260 KB |
testcase_02 | AC | 65 ms
317,276 KB |
testcase_03 | MLE | - |
testcase_04 | AC | 95 ms
352,040 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 | 66 ms
317,400 KB |
testcase_13 | AC | 66 ms
315,352 KB |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | AC | 65 ms
315,360 KB |
testcase_19 | MLE | - |
testcase_20 | AC | 67 ms
319,476 KB |
testcase_21 | MLE | - |
testcase_22 | MLE | - |
testcase_23 | MLE | - |
testcase_24 | MLE | - |
testcase_25 | MLE | - |
testcase_26 | AC | 66 ms
316,268 KB |
testcase_27 | MLE | - |
testcase_28 | MLE | - |
testcase_29 | AC | 65 ms
315,100 KB |
testcase_30 | AC | 66 ms
315,360 KB |
testcase_31 | MLE | - |
ソースコード
#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; } }