結果
問題 |
No.1935 Water Simulation
|
ユーザー |
![]() |
提出日時 | 2022-05-14 02:35:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 768 bytes |
コンパイル時間 | 2,245 ms |
コンパイル使用メモリ | 204,528 KB |
最終ジャッジ日時 | 2025-01-29 07:51:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 4 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); vector<int> V(4),A(4); rep(i,4) cin>>V[i]; A[0]=V[0]; ll n; cin>>n; auto f=[&](int i){ int dif=min(V[(i+1)%4]-A[(i+1)%4],A[i]); A[(i+1)%4]+=dif; A[i]-=dif; }; map<vector<int>,int> m; m[A]=0; int cnt=0,c,a,b; while(1){ cnt++; f((cnt-1)%4); if(cnt%4==0 && m.count(A)){ a=m[A]; b=cnt-a; c=cnt-1; break; } m[A]=cnt; } n=(n-a)%b+a; for(auto [p,q]:m){ if(q==n){ cout<<p[0]<<" "<<p[1]<<" "<<p[2]<<" "<<p[3]<<endl; return 0; } } return 0; }