QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#546211 | #834. Disjoint LIS | qwqUwU_ | AC ✓ | 689ms | 3728kb | C++14 | 1.5kb | 2024-09-03 20:57:11 | 2024-09-03 20:57:12 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
const int mod=998244353;
inline int fp(int x,ll p=mod-2,int m=mod,int res=1){
for(;p;p>>=1){if(p&1)res=1ll*res*x%m;x=1ll*x*x%m;}
return res;
}
inline void Ad(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
inline void Mi(int &x,int y){x=x-y<0?x-y+mod:x-y;}
const int N=200;
int n,iv[N],fac[N],inv[N];
int a[N],tt;
int res;
inline void ck(){
int ans=fac[n];
rep(i,1,tt)rep(j,1,a[i]){
int c=a[i]-j+1;
rep(k,i+1,tt)c+=a[k]>=j;
ans=1ll*ans*iv[c]%mod;
}
Ad(res,1ll*ans*ans%mod);
}
inline void dfs(int x,int p){
if(x==0){ck();return;}
++tt;
rep(i,1,min(p,x)) a[tt]=i,dfs(x-i,i);
--tt;
}
int main() {
//freopen("data.in", "r", stdin);
// freopen("myans.out","w",stdout);
n=read();
iv[1]=1;rep(i,2,N-1)iv[i]=1ll*iv[mod%i]*(mod-mod/i)%mod;
fac[0]=inv[0]=1;rep(i,1,N-1)fac[i]=1ll*fac[i-1]*i%mod,inv[i]=fp(fac[i]);
tt=2;
rep(i,1,n>>1){
a[1]=a[2]=i;
dfs(n-i-i,i);
}
cout<<res;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
6
output:
132
result:
ok 1 number(s): "132"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
1
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
2
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
3
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
4
output:
5
result:
ok 1 number(s): "5"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
5
output:
26
result:
ok 1 number(s): "26"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
7
output:
834
result:
ok 1 number(s): "834"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
8
output:
6477
result:
ok 1 number(s): "6477"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
9
output:
56242
result:
ok 1 number(s): "56242"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
10
output:
532712
result:
ok 1 number(s): "532712"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
11
output:
5561524
result:
ok 1 number(s): "5561524"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
12
output:
64098432
result:
ok 1 number(s): "64098432"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
13
output:
806184757
result:
ok 1 number(s): "806184757"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
14
output:
948233294
result:
ok 1 number(s): "948233294"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
15
output:
989748344
result:
ok 1 number(s): "989748344"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
16
output:
143602156
result:
ok 1 number(s): "143602156"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
17
output:
634648323
result:
ok 1 number(s): "634648323"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
18
output:
421103776
result:
ok 1 number(s): "421103776"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
19
output:
925864750
result:
ok 1 number(s): "925864750"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
20
output:
797907052
result:
ok 1 number(s): "797907052"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
21
output:
912638617
result:
ok 1 number(s): "912638617"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
22
output:
772780014
result:
ok 1 number(s): "772780014"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
23
output:
386111399
result:
ok 1 number(s): "386111399"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
24
output:
327774735
result:
ok 1 number(s): "327774735"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
25
output:
845702948
result:
ok 1 number(s): "845702948"
Test #26:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
26
output:
791619521
result:
ok 1 number(s): "791619521"
Test #27:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
27
output:
878631164
result:
ok 1 number(s): "878631164"
Test #28:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
28
output:
37336541
result:
ok 1 number(s): "37336541"
Test #29:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
29
output:
165629590
result:
ok 1 number(s): "165629590"
Test #30:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
30
output:
969299909
result:
ok 1 number(s): "969299909"
Test #31:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
31
output:
774782650
result:
ok 1 number(s): "774782650"
Test #32:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
32
output:
860045241
result:
ok 1 number(s): "860045241"
Test #33:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
33
output:
866378903
result:
ok 1 number(s): "866378903"
Test #34:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
34
output:
492112739
result:
ok 1 number(s): "492112739"
Test #35:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
35
output:
824431980
result:
ok 1 number(s): "824431980"
Test #36:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
36
output:
949969944
result:
ok 1 number(s): "949969944"
Test #37:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
37
output:
970248926
result:
ok 1 number(s): "970248926"
Test #38:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
38
output:
278772092
result:
ok 1 number(s): "278772092"
Test #39:
score: 0
Accepted
time: 2ms
memory: 3644kb
input:
39
output:
118910029
result:
ok 1 number(s): "118910029"
Test #40:
score: 0
Accepted
time: 2ms
memory: 3648kb
input:
40
output:
190687907
result:
ok 1 number(s): "190687907"
Test #41:
score: 0
Accepted
time: 2ms
memory: 3644kb
input:
41
output:
976616702
result:
ok 1 number(s): "976616702"
Test #42:
score: 0
Accepted
time: 3ms
memory: 3640kb
input:
42
output:
231648679
result:
ok 1 number(s): "231648679"
Test #43:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
43
output:
722078798
result:
ok 1 number(s): "722078798"
Test #44:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
44
output:
677622359
result:
ok 1 number(s): "677622359"
Test #45:
score: 0
Accepted
time: 5ms
memory: 3568kb
input:
45
output:
166145100
result:
ok 1 number(s): "166145100"
Test #46:
score: 0
Accepted
time: 6ms
memory: 3708kb
input:
46
output:
322790432
result:
ok 1 number(s): "322790432"
Test #47:
score: 0
Accepted
time: 7ms
memory: 3700kb
input:
47
output:
114852733
result:
ok 1 number(s): "114852733"
Test #48:
score: 0
Accepted
time: 8ms
memory: 3576kb
input:
48
output:
809056236
result:
ok 1 number(s): "809056236"
Test #49:
score: 0
Accepted
time: 10ms
memory: 3652kb
input:
49
output:
133146712
result:
ok 1 number(s): "133146712"
Test #50:
score: 0
Accepted
time: 12ms
memory: 3560kb
input:
50
output:
978647108
result:
ok 1 number(s): "978647108"
Test #51:
score: 0
Accepted
time: 14ms
memory: 3576kb
input:
51
output:
363079147
result:
ok 1 number(s): "363079147"
Test #52:
score: 0
Accepted
time: 16ms
memory: 3640kb
input:
52
output:
447411358
result:
ok 1 number(s): "447411358"
Test #53:
score: 0
Accepted
time: 20ms
memory: 3540kb
input:
53
output:
261833982
result:
ok 1 number(s): "261833982"
Test #54:
score: 0
Accepted
time: 23ms
memory: 3516kb
input:
54
output:
586593658
result:
ok 1 number(s): "586593658"
Test #55:
score: 0
Accepted
time: 31ms
memory: 3520kb
input:
55
output:
543018772
result:
ok 1 number(s): "543018772"
Test #56:
score: 0
Accepted
time: 33ms
memory: 3644kb
input:
56
output:
281510931
result:
ok 1 number(s): "281510931"
Test #57:
score: 0
Accepted
time: 39ms
memory: 3576kb
input:
57
output:
509498959
result:
ok 1 number(s): "509498959"
Test #58:
score: 0
Accepted
time: 46ms
memory: 3644kb
input:
58
output:
499059113
result:
ok 1 number(s): "499059113"
Test #59:
score: 0
Accepted
time: 55ms
memory: 3652kb
input:
59
output:
216456979
result:
ok 1 number(s): "216456979"
Test #60:
score: 0
Accepted
time: 64ms
memory: 3704kb
input:
60
output:
892597175
result:
ok 1 number(s): "892597175"
Test #61:
score: 0
Accepted
time: 76ms
memory: 3708kb
input:
61
output:
288388296
result:
ok 1 number(s): "288388296"
Test #62:
score: 0
Accepted
time: 90ms
memory: 3564kb
input:
62
output:
782889761
result:
ok 1 number(s): "782889761"
Test #63:
score: 0
Accepted
time: 105ms
memory: 3640kb
input:
63
output:
259994934
result:
ok 1 number(s): "259994934"
Test #64:
score: 0
Accepted
time: 125ms
memory: 3656kb
input:
64
output:
668319048
result:
ok 1 number(s): "668319048"
Test #65:
score: 0
Accepted
time: 142ms
memory: 3712kb
input:
65
output:
447568639
result:
ok 1 number(s): "447568639"
Test #66:
score: 0
Accepted
time: 171ms
memory: 3652kb
input:
66
output:
974154792
result:
ok 1 number(s): "974154792"
Test #67:
score: 0
Accepted
time: 201ms
memory: 3704kb
input:
67
output:
434978721
result:
ok 1 number(s): "434978721"
Test #68:
score: 0
Accepted
time: 236ms
memory: 3648kb
input:
68
output:
809640594
result:
ok 1 number(s): "809640594"
Test #69:
score: 0
Accepted
time: 275ms
memory: 3636kb
input:
69
output:
541844549
result:
ok 1 number(s): "541844549"
Test #70:
score: 0
Accepted
time: 321ms
memory: 3648kb
input:
70
output:
9840250
result:
ok 1 number(s): "9840250"
Test #71:
score: 0
Accepted
time: 375ms
memory: 3580kb
input:
71
output:
275431656
result:
ok 1 number(s): "275431656"
Test #72:
score: 0
Accepted
time: 431ms
memory: 3520kb
input:
72
output:
31040948
result:
ok 1 number(s): "31040948"
Test #73:
score: 0
Accepted
time: 506ms
memory: 3576kb
input:
73
output:
964592956
result:
ok 1 number(s): "964592956"
Test #74:
score: 0
Accepted
time: 589ms
memory: 3708kb
input:
74
output:
743394989
result:
ok 1 number(s): "743394989"
Test #75:
score: 0
Accepted
time: 689ms
memory: 3656kb
input:
75
output:
89362287
result:
ok 1 number(s): "89362287"