結果
問題 |
No.1935 Water Simulation
|
ユーザー |
|
提出日時 | 2022-05-13 22:15:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,582 bytes |
コンパイル時間 | 2,281 ms |
コンパイル使用メモリ | 205,196 KB |
最終ジャッジ日時 | 2025-01-29 07:07:46 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef _RUTHEN #include "debug.hpp" #else #define show(...) true #endif using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) template <class T> using V = vector<T>; int main() { ios::sync_with_stdio(false); cin.tie(0); V<int> a(4); for (int i = 0; i < 4; i++) cin >> a[i]; ll N; cin >> N; if (N <= 10000000) { V<int> b = {a[0], 0, 0, 0}; rep(i, N) { int from = (i + 1 + 3) % 4, to = (i + 1) % 4; int t = min(b[from], a[to] - b[to]); b[from] -= t; b[to] += t; } cout << b[0] << ' ' << b[1] << ' ' << b[2] << ' ' << b[3] << '\n'; return 0; } map<V<int>, int> mp; V<int> b = {a[0], 0, 0, 0}; mp[b] = 0; int cnt = 1; while (true) { int from = (cnt + 3) % 4, to = cnt % 4; int t = min(b[from], a[to] - b[to]); b[from] -= t; b[to] += t; show(b); if (cnt == N) { cout << b[0] << ' ' << b[1] << ' ' << b[2] << ' ' << b[3] << '\n'; return 0; } if (mp.count(b)) { int cy = cnt - mp[b]; int mpb = mp[b]; show(cy); N -= mp[b]; N %= cy; for (auto& [bb, c] : mp) { if (c == N + mpb) { cout << bb[0] << ' ' << bb[1] << ' ' << bb[2] << ' ' << bb[3] << '\n'; return 0; } } } else { mp[b] = cnt++; } } return 0; }