結果

問題 No.1548 [Cherry 2nd Tune B] 貴方と私とサイクルとモーメント
ユーザー 👑 kmjpkmjp
提出日時 2021-06-12 00:16:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,790 bytes
コンパイル時間 2,829 ms
コンパイル使用メモリ 217,240 KB
実行使用メモリ 44,244 KB
最終ジャッジ日時 2023-08-21 15:33:55
合計ジャッジ時間 16,472 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
44,084 KB
testcase_01 AC 21 ms
43,972 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
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 AC 297 ms
44,088 KB
testcase_33 AC 372 ms
44,160 KB
testcase_34 AC 373 ms
44,032 KB
testcase_35 AC 381 ms
44,024 KB
testcase_36 AC 381 ms
43,864 KB
testcase_37 WA -
testcase_38 AC 295 ms
44,088 KB
testcase_39 AC 376 ms
44,096 KB
testcase_40 AC 381 ms
44,020 KB
testcase_41 AC 376 ms
43,988 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘void solve()’ 内:
main.cpp:110:29: 警告: ‘s’ may be used uninitialized [-Wmaybe-uninitialized]
  110 |                         s=(s%mo+mo)%mo*modpow(S[0])%mo;
      |                            ~^~~
main.cpp:106:28: 備考: ‘s’ はここで定義されています
  106 |                         ll s;
      |                            ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

const ll mo=998244353;
template<class V,int NV> class SegTree_sum {
public:
	vector<V> val,sum;
	
	SegTree_sum(){val.resize(NV*2); sum.resize(NV*2,-1);};
	
	V getval(int x,int y,int l=0,int r=NV,int k=1) {
		if(r<=x || y<=l) return 0;
		if(x<=l && r<=y) return sum[k];
		if(val[k]>=0) return val[k]*(min(y,r)-max(l,x))%mo;
		return (getval(x,y,l,(l+r)/2,k*2)+getval(x,y,(l+r)/2,r,k*2+1))%mo;
	}
	
	void update(int x,int y,int v,int l=0,int r=NV,int k=1) {
		if(r<=x || y<=l) return;
		if(x<=l&&r<=y) {
			val[k]=v;
			sum[k]=1LL*v*(r-l)%mo;
		}
		else {
			if(val[k]!=-1) {
				update(x,y,val[k],l,(l+r)/2,k*2);
				update(x,y,val[k],(l+r)/2,r,k*2+1);
				val[k]=-1;
			}
			update(x,y,v,l,(l+r)/2,k*2);
			update(x,y,v,(l+r)/2,r,k*2+1);
			sum[k]=(sum[2*k]+sum[2*k+1])%mo;
		}
	}
};
SegTree_sum<ll,1<<18> st[5];
int N,Q;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		ll v,w=1;
		cin>>v;
		for(j=1;j<=4;j++) {
			w=w*v%mo;
			st[j].update(i,i+1,w);
		}
	}
	cin>>Q;
	while(Q--) {
		int U,V,W;
		cin>>i>>U>>V>>W;
		U--,V--,W--;
		if(U>V) swap(U,V);
		if(W<U||V<W) swap(U,V);
		if(i==0) {
			ll v,w=1;
			cin>>v;
			for(j=1;j<=4;j++) {
				w=w*v%mo;
				if(U<V) {
					st[j].update(U,V+1,w);
				}
				else {
					st[j].update(0,V+1,w);
					st[j].update(U,N,w);
				}
			}
		}
		else if(i==1) {
			cout<<0<<endl;
		}
		else {
			ll S[5]={};
			if(U<V) S[0]=V-U+1;
			else S[0]=V+1+(N-U);
			for(j=1;j<=4;j++) {
				if(U<V) {
					S[j]=st[j].getval(U,V+1);
				}
				else {
					S[j]=(st[j].getval(0,V+1)+st[j].getval(U,N))%mo;
				}
			}
			ll M=S[1]*modpow(S[0])%mo;
			ll s;
			if(i==2) s=S[2]-2*S[1]*M%mo+S[0]*M%mo*M%mo;
			if(i==3) s=S[3]-3*S[2]*M%mo+3*S[1]*M%mo*M%mo-S[0]*M%mo*M%mo*M%mo;
			if(i==4) s=S[4]-4*S[3]*M%mo+6*S[2]*M%mo*M%mo-4*S[1]*M%mo*M%mo*M%mo+S[0]*M%mo*M%mo*M%mo*M%mo;
			s=(s%mo+mo)%mo*modpow(S[0])%mo;
			cout<<s<<endl;
			
			
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0