Submission #54594535


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,a,c[1010][1010],ans;
long long f[30][1010];
long long t;
int main() {
cin>>n;
f[0][0]=1;
for (int i=0;i<=n;i++) c[i][0]=1;
for (int i=1;i<=n;i++) for (int j=1;j<=i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
for (int i=1;i<=26;i++) {
cin>>a;
a=min(n,a);
for (int j=0;j<=n;j++) for (int k=j-a;k<=j;k++) f[i][j]=(f[i][j]+f[i-1][k]*c[j][k])%mod;
}
for (int i=1;i<=n;i++) ans=(ans+f[26][i])%mod;
cout<<ans<<endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n,a,c[1010][1010],ans;
long long f[30][1010];
long long t;
int main() {
    cin>>n;
    f[0][0]=1;
    for (int i=0;i<=n;i++) c[i][0]=1;
    for (int i=1;i<=n;i++) for (int j=1;j<=i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
    for (int i=1;i<=26;i++) {
        cin>>a;
        a=min(n,a);
        for (int j=0;j<=n;j++) for (int k=j-a;k<=j;k++) f[i][j]=(f[i][j]+f[i-1][k]*c[j][k])%mod;
    }
    for (int i=1;i<=n;i++) ans=(ans+f[26][i])%mod;
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task E - Alphabet Tiles
User undefined_Ryan
Language C++ 20 (gcc 12.2)
Score 475
Code Size 559 Byte
Status AC
Exec Time 88 ms
Memory 7660 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 22
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 3760 KB
sample01.txt AC 2 ms 5088 KB
sample02.txt AC 88 ms 7660 KB
testcase00.txt AC 3 ms 5760 KB
testcase01.txt AC 2 ms 5436 KB
testcase02.txt AC 2 ms 5596 KB
testcase03.txt AC 4 ms 4480 KB
testcase04.txt AC 10 ms 5264 KB
testcase05.txt AC 3 ms 4200 KB
testcase06.txt AC 46 ms 7420 KB
testcase07.txt AC 25 ms 5828 KB
testcase08.txt AC 19 ms 5756 KB
testcase09.txt AC 1 ms 4004 KB
testcase10.txt AC 42 ms 7160 KB
testcase11.txt AC 32 ms 6504 KB
testcase12.txt AC 7 ms 4876 KB
testcase13.txt AC 2 ms 3776 KB
testcase14.txt AC 29 ms 6536 KB
testcase15.txt AC 6 ms 4592 KB
testcase16.txt AC 35 ms 7116 KB
testcase17.txt AC 2 ms 4044 KB
testcase18.txt AC 2 ms 5828 KB


2025-03-05 (Wed)
20:46:25 +00:00