QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#339127 | #8047. DFS Order 4 | 369Pai | AC ✓ | 558ms | 8688kb | C++23 | 934b | 2024-02-26 19:37:39 | 2024-02-26 19:37:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned uint;
const int N = 805;
int n , mod , c[N][N] , f[N][N];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0) , cout.tie(0);
cin >> n >> mod;
for(int i = 0 ; i <= n ; i++)
{
c[i][0] = 1;
for(int j = 1 ; j <= i ; j++)
{
uint t = c[i - 1][j - 1] + c[i - 1][j];
c[i][j] = (t >= (uint)mod ? t - mod : t);
}
}
for(int i = 0 ; i <= n ; i++)
f[0][i] = f[1][i] = 1;
for(int i = 2 ; i <= n ; i++)
{
for(int j = 0 ; i + j <= n ; j++)
{
for(int x = 1 ; x <= i - 2 ; x++)
{
int y = i - 1 - x;
f[i][j] = (f[i][j] + (ll)f[y][j] * ((ll)f[x][0] * c[i - 1 + j][x] % mod - f[x][y + j])) % mod;
}
f[i][j] = (f[i][j] + (ll)f[i - 1][0] * c[i - 1 + j][i - 1]) % mod;
// cerr << i << ',' << j << " " << f[i][j] << "\n";
}
}
cout << (f[n - 1][0] + mod) % mod << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5676kb
input:
4 114514199
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5732kb
input:
10 998244353
output:
11033
result:
ok 1 number(s): "11033"
Test #3:
score: 0
Accepted
time: 2ms
memory: 6040kb
input:
100 1000000007
output:
270904395
result:
ok 1 number(s): "270904395"
Test #4:
score: 0
Accepted
time: 464ms
memory: 8532kb
input:
756 1001338769
output:
901942543
result:
ok 1 number(s): "901942543"
Test #5:
score: 0
Accepted
time: 541ms
memory: 8640kb
input:
793 1009036033
output:
301770320
result:
ok 1 number(s): "301770320"
Test #6:
score: 0
Accepted
time: 467ms
memory: 8572kb
input:
759 1005587659
output:
846376219
result:
ok 1 number(s): "846376219"
Test #7:
score: 0
Accepted
time: 496ms
memory: 8532kb
input:
773 1007855479
output:
1398019
result:
ok 1 number(s): "1398019"
Test #8:
score: 0
Accepted
time: 458ms
memory: 8496kb
input:
751 1006730639
output:
321287237
result:
ok 1 number(s): "321287237"
Test #9:
score: 0
Accepted
time: 506ms
memory: 8616kb
input:
778 1007760653
output:
430322899
result:
ok 1 number(s): "430322899"
Test #10:
score: 0
Accepted
time: 558ms
memory: 8596kb
input:
798 1007543827
output:
688720826
result:
ok 1 number(s): "688720826"
Test #11:
score: 0
Accepted
time: 543ms
memory: 8688kb
input:
796 1004841413
output:
258829347
result:
ok 1 number(s): "258829347"
Test #12:
score: 0
Accepted
time: 500ms
memory: 8620kb
input:
775 1005185189
output:
744278608
result:
ok 1 number(s): "744278608"
Test #13:
score: 0
Accepted
time: 547ms
memory: 8672kb
input:
800 1006012831
output:
508549367
result:
ok 1 number(s): "508549367"
Test #14:
score: 0
Accepted
time: 1ms
memory: 5620kb
input:
1 1001338769
output:
1
result:
ok 1 number(s): "1"
Test #15:
score: 0
Accepted
time: 1ms
memory: 5664kb
input:
2 1001338769
output:
1
result:
ok 1 number(s): "1"
Test #16:
score: 0
Accepted
time: 0ms
memory: 5696kb
input:
9 1009036033
output:
1780
result:
ok 1 number(s): "1780"
Test #17:
score: 0
Accepted
time: 1ms
memory: 5720kb
input:
14 1001338769
output:
43297358
result:
ok 1 number(s): "43297358"
Extra Test:
score: 0
Extra Test Passed