Submission #74893236


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
const int Mod=998244353;
long long dp[5001][5001];
int l[20001],r[20001];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)cin>>l[i]>>r[i];
    dp[0][n]=1;
    for(int i=1;i<=n-1;i++){
        for(int j=0;j<=n-i;j++){
            if(j+1<=n-i+1&&l[i]<=j+1&&j+1<=r[i]){
                dp[i][j]=(dp[i][j]+dp[i-1][j+1])%Mod;
            }
            if(n-i+j+1<=n&&l[i]<=n-i+j+1&&n-i+j+1<=r[i]){
                dp[i][j]=(dp[i][j]+dp[i-1][j])%Mod;
            }
        }
    }
    long long ans=0;
    for(int j=1;j<=n-2;j++){
        ans=(ans+dp[n-1][j])%Mod;
    }
    cout<<ans;
    return 0;
}

Submission Info

Submission Time
Task E - Team Division
User ywrow
Language C++23 (GCC 15.2.0)
Score 0
Code Size 680 Byte
Status RE
Exec Time 100 ms
Memory 3552 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 475
Status
WA × 2
WA × 2
RE × 33
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt WA 2 ms 3440 KiB
example_01.txt WA 1 ms 3412 KiB
hand_00.txt RE 97 ms 3500 KiB
hand_01.txt RE 99 ms 3436 KiB
hand_02.txt RE 99 ms 3372 KiB
hand_03.txt RE 98 ms 3396 KiB
hand_04.txt RE 96 ms 3412 KiB
hand_05.txt RE 98 ms 3368 KiB
hand_06.txt RE 97 ms 3552 KiB
hand_07.txt RE 99 ms 3408 KiB
random_00.txt RE 98 ms 3384 KiB
random_01.txt RE 99 ms 3372 KiB
random_02.txt RE 97 ms 3500 KiB
random_03.txt RE 100 ms 3236 KiB
random_04.txt RE 98 ms 3524 KiB
random_05.txt RE 96 ms 3412 KiB
random_06.txt RE 96 ms 3424 KiB
random_07.txt RE 96 ms 3332 KiB
random_08.txt RE 95 ms 3424 KiB
random_09.txt RE 96 ms 3500 KiB
random_10.txt RE 96 ms 3368 KiB
random_11.txt RE 98 ms 3384 KiB
random_12.txt RE 100 ms 3348 KiB
random_13.txt RE 99 ms 3368 KiB
random_14.txt RE 99 ms 3496 KiB
random_15.txt RE 98 ms 3236 KiB
random_16.txt RE 98 ms 3372 KiB
random_17.txt RE 98 ms 3364 KiB
random_18.txt RE 98 ms 3236 KiB
random_19.txt RE 97 ms 3380 KiB
random_20.txt RE 98 ms 3424 KiB
random_21.txt RE 100 ms 3368 KiB
random_22.txt RE 99 ms 3444 KiB
random_23.txt RE 98 ms 3424 KiB
random_24.txt RE 97 ms 3372 KiB