結果
問題 | No.1935 Water Simulation |
ユーザー | Rubikun |
提出日時 | 2022-05-13 21:31:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,327 bytes |
コンパイル時間 | 2,295 ms |
コンパイル使用メモリ | 205,500 KB |
最終ジャッジ日時 | 2025-01-29 06:38:06 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005; const ll INF=1LL<<60; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); vector<int> V(4); for(int i=0;i<4;i++) cin>>V[i]; ll N;cin>>N; map<vector<int>,int> MA; vector<int> now(4);now[0]=V[0]; MA[now]=0; int syuu=-1; for(int t=4;;t+=4){ for(int i=0;i<4;i++){ int x=min(now[i],V[(i+1)%4]-now[(i+1)%4]); now[i]-=x; now[(i+1)%4]+=x; } if(MA.count(now)){ syuu=t-MA[now]; break; }else{ MA[now]=t; } } ll can=N/syuu-2; chmax(can,0LL); N-=can*syuu; for(ll t=0;t<N;t++){ int x=min(now[t%4],V[(t+1)%4]-now[(t+1)%4]); now[t%4]-=x; now[(t+1)%4]+=x; } for(int i=0;i<4;i++){ cout<<now[i]<<" "; } cout<<endl; }