結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 3 ms
11,512 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 4 ms
11,860 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
11,592 KB
testcase_21 AC 4 ms
12,040 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 4 ms
12,864 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
11,532 KB
testcase_28 WA -
testcase_29 AC 3 ms
9,460 KB
testcase_30 AC 3 ms
9,520 KB
testcase_31 AC 3 ms
11,536 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[1010101];
int vb[1010101];
int vc[1010101];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d,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