結果
| 問題 |
No.1935 Water Simulation
|
| コンテスト | |
| ユーザー |
yuyu_5510
|
| 提出日時 | 2022-05-13 23:51:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,127 bytes |
| コンパイル時間 | 1,903 ms |
| コンパイル使用メモリ | 178,256 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 04:37:56 |
| 合計ジャッジ時間 | 2,827 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
int main(){
vector<ll> v(4);
vector<ll> h(4,0);
for(int i = 0;i < 4;++i){
cin >> v[i];
}
h[0] = 1LL;
h[1] = 10000LL;
h[2] = 100000000LL;
h[3] = 1000000000000LL;
ll n;
cin >> n;
ll cnt = 0;
vector<ll> mizu(4);
ll now = 0;
std::map<pair<ll, ll>,ll> pl;
mizu[0] = v[0];
pl[make_pair(v[0], 0)] = 0;
bool first = false;
while(n > 0){
++cnt;
--n;
ll ryo = min(mizu[now], v[(now+1)%4]-mizu[(now+1)%4]);
mizu[now] -= ryo;
mizu[(now+1)%4] += ryo;
ll nxt = mizu[0]*h[0] + mizu[1]*h[1] + mizu[2]*h[2] + mizu[3]*h[3];
now += 1;
now %= 4;
if(pl.count(make_pair(nxt, now)) >= 1 && first == false){
ll pre = pl[make_pair(nxt, now)];
ll kaisu = cnt - pre;
ll tmp = n/kaisu;
n = n-(kaisu*tmp);
first = true;
}
pl[make_pair(nxt, now)] = cnt;
}
for(int i = 0;i < 4;++i){
cout << mizu[i] << ' ';
}
cout << endl;
}
yuyu_5510