結果
問題 | No.1935 Water Simulation |
ユーザー | 3mEhsfd8aG5jx2t |
提出日時 | 2022-05-13 23:51:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,992 bytes |
コンパイル時間 | 2,391 ms |
コンパイル使用メモリ | 215,700 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-22 04:38:11 |
合計ジャッジ時間 | 3,368 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 3 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,944 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for(long long i = 0; i < (long long)(n); i++) using ll = long long; using namespace std; struct S { int id = 0; ll v1, v2, v3, v4; S(ll mv1, ll mv2, ll mv3, ll mv4) : v1(mv1), v2(mv2), v3(mv3), v4(mv4) {} }; bool operator<(const S &l, const S &r) noexcept { if(l.v1 != r.v1) return l.v1 < r.v1; if(l.v2 != r.v2) return l.v2 < r.v2; if(l.v3 != r.v3) return l.v3 < r.v3; if(l.v4 != r.v4) return l.v4 < r.v4; return l.id < r.id; } int main() { ll v1, v2, v3, v4, N; cin >> v1 >> v2 >> v3 >> v4 >> N; map<S, ll> mp; set<S> s; S now(v1, 0, 0, 0); bool skip = false; REP(i, N) { now.id = i % 4; if(i % 4 == 0) { { // 1 ll add = v2 - now.v2; add = min(add, now.v1); now.v1 -= add, now.v2 += add; } } if(i % 4 == 1) { { // 2 ll add = v3 - now.v3; add = min(add, now.v2); now.v2 -= add, now.v3 += add; } } if(i % 4 == 2) { { // 3 ll add = v4 - now.v4; add = min(add, now.v3); now.v3 -= add, now.v4 += add; } } if(i % 4 == 3) { { // 1 ll add = v1 - now.v1; add = min(add, now.v4); now.v4 -= add, now.v1 += add; } } if(!skip && mp.count(now)) { ll dist = i - mp[now]; ll remain = N - i-1; remain = (remain / dist) * dist; if(remain > 0) { i += remain; } skip = true; } mp[now] = i; s.insert(now); } cerr << mp.size() << endl; cout << now.v1 << " " << now.v2 << " " << now.v3 << " " << now.v4 << endl; // printf("%lld %lld %lld %lld\n", now.v1, now.v2, now.v3, now.v4); }