結果
問題 | No.1549 [Cherry 2nd Tune] BANning Tuple |
ユーザー | kotatsugame |
提出日時 | 2021-06-11 23:59:47 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,750 ms / 4,000 ms |
コード長 | 1,493 bytes |
コンパイル時間 | 1,185 ms |
コンパイル使用メモリ | 96,264 KB |
実行使用メモリ | 6,712 KB |
最終ジャッジ日時 | 2023-08-21 15:15:13 |
合計ジャッジ時間 | 34,187 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
4,536 KB |
testcase_01 | AC | 45 ms
4,656 KB |
testcase_02 | AC | 93 ms
4,816 KB |
testcase_03 | AC | 940 ms
5,488 KB |
testcase_04 | AC | 1,019 ms
5,692 KB |
testcase_05 | AC | 752 ms
5,464 KB |
testcase_06 | AC | 740 ms
5,408 KB |
testcase_07 | AC | 2,750 ms
6,592 KB |
testcase_08 | AC | 2,463 ms
6,408 KB |
testcase_09 | AC | 2,339 ms
6,492 KB |
testcase_10 | AC | 2,188 ms
6,520 KB |
testcase_11 | AC | 2,445 ms
6,468 KB |
testcase_12 | AC | 2,254 ms
6,712 KB |
testcase_13 | AC | 2,244 ms
6,512 KB |
testcase_14 | AC | 2,339 ms
6,596 KB |
testcase_15 | AC | 2,272 ms
6,328 KB |
testcase_16 | AC | 2,311 ms
6,384 KB |
testcase_17 | AC | 2,279 ms
6,536 KB |
testcase_18 | AC | 2,324 ms
6,708 KB |
testcase_19 | AC | 48 ms
4,776 KB |
コンパイルメッセージ
main.cpp:11:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type] 11 | main() | ^~~~
ソースコード
#include<iostream> #include<map> #include<set> #include<vector> #include<atcoder/modint> using namespace std; using mint=atcoder::modint998244353; long N; int Q; mint C[101][3001]; main() { cin>>N>>Q; for(int i=0;i<=100;i++) { mint x=1,y=1; for(int j=0;j<=3000;j++) { C[i][j]=x/y; x*=N-i+j+1; y*=j+1; } } map<long,set<pair<int,int> > >mp; for(int q=0;q<Q;q++) { long K;int A,B,S,T; cin>>K>>A>>B>>S>>T; B++; { set<pair<int,int> >now; for(pair<int,int>p:mp[K]) { if(p.second<A)now.insert(p); else if(B<p.first)now.insert(p); else { if(A>p.first)A=p.first; if(B<p.second)B=p.second; } } now.insert(make_pair(A,B)); mp[K].swap(now); } vector<vector<mint> >dp(mp.size()+1,vector<mint>(T+1)); dp[0][0]=1; int cnt=0; for(auto&&S:mp) { vector<vector<mint> >ep(cnt+2,vector<mint>(T+1)); for(int i=cnt;i>=0;i--) { for(pair<int,int>p:S.second) { int a=p.first,b=p.second; for(int j=0;j+a<=T;j++) { ep[i+1][j+a]+=dp[i][j]; int r=j+b; if(r<=T)ep[i+1][r]-=dp[i][j]; } } } cnt++; for(int i=0;i<=cnt;i++) { for(int j=1;j<=T;j++)ep[i][j]+=ep[i][j-1]; for(int j=0;j<=T;j++)dp[i][j]+=ep[i][j]; } } mint ans=0; for(int i=0;i<=cnt;i++) { for(int j=0;j<=T;j++) { mint f=dp[i][j]; if(i&1)f=-f; mint val=C[i][T-j]; if(S>j) { val-=C[i][S-j-1]; } ans+=f*val; } } cout<<ans.val()<<endl; } }