結果
問題 | No.1935 Water Simulation |
ユーザー | shinchan |
提出日時 | 2022-05-13 21:51:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,599 bytes |
コンパイル時間 | 2,159 ms |
コンパイル使用メモリ | 217,336 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 04:33:58 |
合計ジャッジ時間 | 3,099 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i<n;i++) #define all(i, v) for(auto& i : v) typedef long long ll; using namespace std; const ll mod=1000000007, INF=(1LL<<60); #define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl; ll hen(vector<ll> a) { return ((a[0] * 101 + a[1]) *101 + a[2]) *101 + a[3]; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); ll v[4], n; rep(i, 4) cin >> v[i]; cin >> n; if(n <= 10000) { vector<ll> h(4, 0); h[0] = v[0]; ll id = 0; while(n--) { // rep(i, 4) cout << h[i] << " "; // cout << endl; ll nx = (id + 1) % 4; ll num1 = h[id]; ll num2 = v[nx] - h[nx]; ll num = min(num1, num2); h[id] -= num; h[nx] += num; id++; id %= 4; } rep(i, 4) cout << h[i] << " "; cout << endl; return 0; } ll min_id = 0, num = 10000; rep(i, 4) { if(v[i] < num) { min_id = i; num = v[i]; } } vector<ll> h(4, 0); h[0] = v[0]; ll id = 0; rep(i, min_id) { n--; ll nx = (id + 1) % 4; ll num1 = h[id]; ll num2 = v[nx] - h[nx]; ll num = min(num1, num2); h[id] -= num; h[nx] += num; id++; id %= 4; } set<ll> seen; map<ll, ll> mp; while(n >= 4) { if(seen.count(hen(h))) { break; } seen.insert(hen(h)); mp[hen(h)] = n; rep(i, 4) { ll nx = (id + 1) % 4; ll num1 = h[id]; ll num2 = v[nx] - h[nx]; ll num = min(num1, num2); h[id] -= num; h[nx] += num; id++; id %= 4; } n -= 4; } if(n <= 3) { while(n--) { ll nx = (id + 1) % 4; ll num1 = h[id]; ll num2 = v[nx] - h[nx]; ll num = min(num1, num2); h[id] -= num; h[nx] += num; id++; id %= 4; } rep(i, 4) cout << h[i] << " "; cout << endl; return 0; } n %= mp[hen(h)] - n; while(n--) { ll nx = (id + 1) % 4; ll num1 = h[id]; ll num2 = v[nx] - h[nx]; ll num = min(num1, num2); h[id] -= num; h[nx] += num; id++; id %= 4; } rep(i, 4) cout << h[i] << " "; cout << endl; return 0; }