結果
| 問題 |
No.1935 Water Simulation
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2022-05-14 03:13:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,428 bytes |
| コンパイル時間 | 2,189 ms |
| コンパイル使用メモリ | 205,872 KB |
| 最終ジャッジ日時 | 2025-01-29 07:53:30 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 4 |
ソースコード
#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);
if(N>=10000000) N-=can*syuu;
for(int i=0;i<4;i++){
if(i==0) now[i]=V[0];
else now[i]=0;
}
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;
}
Rubikun