結果

問題 No.1935 Water Simulation
ユーザー gs18115gs18115
提出日時 2022-05-13 21:50:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,499 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 70,520 KB
実行使用メモリ 13,296 KB
最終ジャッジ日時 2023-09-29 06:59:09
合計ジャッジ時間 1,751 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 3 ms
11,552 KB
testcase_05 AC 2 ms
12,504 KB
testcase_06 AC 3 ms
12,424 KB
testcase_07 AC 2 ms
11,844 KB
testcase_08 AC 2 ms
12,128 KB
testcase_09 AC 3 ms
12,680 KB
testcase_10 AC 2 ms
12,272 KB
testcase_11 AC 3 ms
11,528 KB
testcase_12 AC 2 ms
11,692 KB
testcase_13 AC 2 ms
11,552 KB
testcase_14 AC 3 ms
11,592 KB
testcase_15 AC 2 ms
11,764 KB
testcase_16 AC 3 ms
12,280 KB
testcase_17 AC 2 ms
11,644 KB
testcase_18 AC 2 ms
11,528 KB
testcase_19 AC 3 ms
12,336 KB
testcase_20 AC 2 ms
11,588 KB
testcase_21 AC 3 ms
12,392 KB
testcase_22 AC 2 ms
11,708 KB
testcase_23 AC 2 ms
11,620 KB
testcase_24 AC 3 ms
13,296 KB
testcase_25 AC 2 ms
12,352 KB
testcase_26 AC 3 ms
11,616 KB
testcase_27 AC 2 ms
11,680 KB
testcase_28 AC 3 ms
11,508 KB
testcase_29 AC 2 ms
9,460 KB
testcase_30 AC 3 ms
11,616 KB
testcase_31 AC 2 ms
11,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
int dp[101][101][101];
int va[1040101];
int vb[1040101];
int vc[1040101];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    ll n;
    cin>>a>>b>>c>>d>>n;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int k=0;k<=c;k++)
                dp[i][j][k]=-1;
    int ca=a,cb=0,cc=0,cd=0;
    dp[ca][cb][cc]=0;
    va[0]=ca;
    int ip=-1,cyc=0;
    for(int i=1;i<=n;i++)
    {
        if(i%4==0)
        {
            int v=min(cd,a-ca);
            cd-=v;
            ca+=v;
        }
        else if(i%4==1)
        {
            int v=min(ca,b-cb);
            ca-=v;
            cb+=v;
        }
        else if(i%4==2)
        {
            int v=min(cb,c-cc);
            cb-=v;
            cc+=v;
        }
        else
        {
            int v=min(cc,d-cd);
            cc-=v;
            cd+=v;
        }
        if(dp[ca][cb][cc]!=-1)
        {
            ip=dp[ca][cb][cc];
            cyc=i-ip;
            break;
        }
        dp[ca][cb][cc]=i;
        va[i]=ca,vb[i]=cb,vc[i]=cc;
    }
    if(ip!=-1)
        n=(n-ip)%cyc+ip;
    cout<<va[n]<<' '<<vb[n]<<' '<<vc[n]<<' '<<a-va[n]-vb[n]-vc[n]<<endl;
    return 0;
}
0