結果

問題 No.2833 Count Taiko Results
ユーザー kotatsugamekotatsugame
提出日時 2024-08-03 00:02:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 87,992 KB
実行使用メモリ 16,480 KB
最終ジャッジ日時 2024-08-03 00:03:10
合計ジャッジ時間 16,726 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 TLE -
testcase_35 WA -
testcase_36 WA -
testcase_37 TLE -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 TLE -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
#include<atcoder/modint>
#include<atcoder/segtree>
#include<atcoder/lazysegtree>
using namespace std;
using mint=atcoder::modint;
using dat=pair<mint,int>;
dat op(dat a,dat b){return make_pair(a.first+b.first,a.second+b.second);}
dat e(){return make_pair(mint::raw(0),0);}
dat mp(mint f,dat x){x.first*=f.pow(x.second);return x;}
mint cmp(mint f,mint g){return f*g;}
mint id(){return mint::raw(1);}
int N;
int A[2<<17],B[2<<17];
mint f(int K)
{
	atcoder::lazy_segtree<dat,op,e,mint,mp,cmp,id>seg(N);
	vector<mint>initA(N),initAB(N);
	for(int i=0;i<N;i++)initA[i]=A[i],initAB[i]=A[i]+B[i];
	atcoder::segtree<mint,cmp,id>segA(initA),segAB(initAB);
	mint ans=0;
	for(int i=0;i+K<=N;i++)
	{
		mint cur=segAB.prod(0,i)-seg.prod(0,i).first;
		seg.set(i,make_pair(cur,1));
		int l=max(0,i-K);
		seg.apply(0,l,A[i]+B[i]);
		seg.apply(l,i+1,A[i]);
		ans+=cur*segA.prod(i,i+K)*segAB.prod(i+K,N);
	}
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int K;
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	cout<<(f(K)-f(K+1)).val()<<endl;
}
0