結果
問題 | No.1935 Water Simulation |
ユーザー |
![]() |
提出日時 | 2023-05-17 23:48:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,324 bytes |
コンパイル時間 | 1,317 ms |
コンパイル使用メモリ | 120,808 KB |
最終ジャッジ日時 | 2025-02-13 01:08:57 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; ll modulo(string &S, ll modc){ ll res = 0; for (auto x : S){ res *= 10; res += x-'0'; res %= modc; } return res; } int main(){ ll N, cnt=0, loop=-1, res; vector<int> v(4); for (int i=0; i<4; i++) cin >> v[i]; cin >> N; vector<int> x(5); x = {v[0], 0, 0, 0, 0}; map<vector<int>, int> mp; vector<vector<int>> a; while(cnt < N){ mp[x] = cnt; a.push_back(x); vector<int> y = x; y[4] = (cnt+1)%4; y[(cnt+1)%4] += min(x[cnt%4], v[(cnt+1)%4]-x[(cnt+1)%4]); y[cnt%4] = x[cnt%4] - min(x[cnt%4], v[(cnt+1)%4]-x[(cnt+1)%4]); cnt++; swap(x, y); if (mp.count(x)){ loop = cnt-mp[x]; break; } } if (N == cnt){ cout << x[0] << " " << x[1] << " " << x[2] << " " << x[3] << endl; return 0; } cnt -= loop; N -= cnt; N %= loop; res = N + cnt; x = a[res]; cout << x[0] << " " << x[1] << " " << x[2] << " " << x[3] << endl; return 0; }