結果

問題 No.1935 Water Simulation
ユーザー HIcoderHIcoder
提出日時 2023-07-18 17:36:47
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,707 bytes
コンパイル時間 2,628 ms
コンパイル使用メモリ 134,652 KB
実行使用メモリ 814,544 KB
最終ジャッジ日時 2023-10-18 20:57:13
合計ジャッジ時間 9,447 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
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;
        */
    }


}
0