提出 #55547792


ソースコード 拡げる

# include <iostream>
using namespace std;

const long long MOD=998244353;
const int MAX=84;
long long a[MAX];
long long br[MAX];
long long dp[MAX][MAX][MAX];
int n;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];

    br[1]=n;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++) dp[j][i][2]=1;
    }

    for(int j=2;j<=n;j++)
    {
        for(int pr=1;pr<j;pr++)
        {
            for(int k=2;k<=n;k++)
            {
                if(dp[j][pr][k]==0) continue;
                //cout<<pr<<" "<<j<<" "<<k<<"\n";
                for(int i=j+1;i<=n;i++)
                {
                    if(a[i]-a[j]==a[j]-a[pr]) {dp[i][j][k+1]=(dp[i][j][k+1]+dp[j][pr][k])%MOD;/*cout<<"->"<<j<<" "<<i<<"\n";*/}
                }
            }
        }
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            for(int k=2;k<=n;k++) br[k]=(br[k]+dp[j][i][k])%MOD;
        }
    }

    for(int i=1;i<=n;i++) cout<<br[i]<<" ";
    cout<<"\n";

    return 0;
}

提出情報

提出日時
問題 E - Count Arithmetic Subsequences
ユーザ denislav
言語 C++ 20 (Clang 16.0.6)
得点 475
コード長 1130 Byte
結果 AC
実行時間 4 ms
メモリ 5872 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 475 / 475
結果
AC × 3
AC × 29
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 1 ms 3484 KiB
00_sample_02.txt AC 1 ms 3460 KiB
00_sample_03.txt AC 1 ms 3428 KiB
01_random_01.txt AC 1 ms 4240 KiB
01_random_02.txt AC 2 ms 5744 KiB
01_random_03.txt AC 2 ms 5732 KiB
01_random_04.txt AC 2 ms 5792 KiB
01_random_05.txt AC 1 ms 3712 KiB
01_random_06.txt AC 2 ms 5852 KiB
01_random_07.txt AC 1 ms 3388 KiB
01_random_08.txt AC 2 ms 5792 KiB
01_random_09.txt AC 1 ms 3428 KiB
01_random_10.txt AC 2 ms 5776 KiB
01_random_11.txt AC 2 ms 5120 KiB
01_random_12.txt AC 2 ms 5872 KiB
01_random_13.txt AC 1 ms 4220 KiB
01_random_14.txt AC 2 ms 5800 KiB
01_random_15.txt AC 2 ms 5384 KiB
01_random_16.txt AC 2 ms 5780 KiB
01_random_17.txt AC 2 ms 5412 KiB
01_random_18.txt AC 2 ms 5792 KiB
01_random_19.txt AC 2 ms 4836 KiB
01_random_20.txt AC 2 ms 5800 KiB
02_handmade_01.txt AC 2 ms 4620 KiB
02_handmade_02.txt AC 4 ms 5736 KiB
02_handmade_03.txt AC 2 ms 5824 KiB
02_handmade_04.txt AC 2 ms 5820 KiB
02_handmade_05.txt AC 3 ms 5816 KiB
02_handmade_06.txt AC 2 ms 5716 KiB