結果
| 問題 |
No.1935 Water Simulation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-18 17:36:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,707 bytes |
| コンパイル時間 | 987 ms |
| コンパイル使用メモリ | 113,392 KB |
| 最終ジャッジ日時 | 2025-02-15 15:36:42 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | MLE * 1 -- * 28 |
ソースコード
/*
MLE
*/
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include<tuple>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;
typedef tuple<int,int,int,int> TP;
//typedef vector<int> TP;
vector<int> V(4);
TP func(const TP& t,int idx){
TP res=t;
auto [t0,t1,t2,t3]=t;
if(idx==0){
get<0>(res) =t0 - min(V[1]-t1,t0);
get<1>(res) =t1 + min(V[1]-t1,t0);
}
else if(idx==1){
get<1>(res) =t1 - min(V[2]-t2,t1);
get<2>(res) =t2 + min(V[2]-t2,t1);
}else if(idx==2){
get<2>(res) =t2 - min(V[3]-t3,t2);
get<3>(res) =t3 + min(V[3]-t3,t2);
}else if(idx==3){
get<3>(res) =t3 - min(V[0]-t0,t3);
get<0>(res) =t0 + min(V[0]-t0,t3);
}
return res;
}
/*
TP func(const TP &t,int idx){
TP res=t;
get<0>(res);
//変数でのアクセスが無理
get<idx>(res) = get<idx>(t) - ;
res[idx]=t[idx] - min(V[(idx+1)%4] - t[(idx+1)%4],t[idx]);
res[(idx+1)%4]=t[(idx+1)%4] + min(V[(idx+1)%4] - t[(idx+1)%4],t[idx]);
return res;
}
*/
int main(){
ll N;
for(int i=0;i<4;i++){
cin>>V[i];
}
cin>>N;
vector<TP> history;
map<TP,int> mp;
auto now=make_tuple(V[0],0,0,0);
int sz=0;
int offset=-1;
vector<TP> cyclehistory;
while(1){
if(mp.count(now)){
if(offset==-1){
offset=mp[now];
cyclehistory.push_back(now);
}else{
if(mp[now]==offset){
break;
}
cyclehistory.push_back(now);
}
}else{
mp[now]=sz;
}
history.push_back(now);
auto nx=func(now,sz%4);
/*
for(int v:nx){
cout<<v<<' ';
}
cout<<endl;
*/
sz++;
now=nx;
}
int cycle=cyclehistory.size();
//cout<<"offset="<<offset<<",cycle="<<cycle<<endl;
if(N<offset){
auto [t0,t1,t2,t3]=history[N];
cout<<t0<<' '<<t1<<' '<<t2<<' '<<t3<<endl;
/*
for(int v:history[N]){
cout<<v<<' ';
}
cout<<endl;
*/
}else{
N-=offset;
N%=cycle;
auto [t0,t1,t2,t3]=cyclehistory[N];
cout<<t0<<' '<<t1<<' '<<t2<<' '<<t3<<endl;
/*
for(int v:cyclehistory[N]){
cout<<v<<' ';
}
cout<<endl;
*/
}
}