結果
問題 | No.1548 [Cherry 2nd Tune B] 貴方と私とサイクルとモーメント |
ユーザー |
![]() |
提出日時 | 2021-06-11 23:11:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 135 ms / 4,500 ms |
コード長 | 2,069 bytes |
コンパイル時間 | 4,585 ms |
コンパイル使用メモリ | 258,980 KB |
最終ジャッジ日時 | 2025-01-22 06:57:57 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 42 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:53:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | scanf("%d",&t); | ~~~~~^~~~~~~~~ main.cpp:69:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 69 | scanf("%d",&t); | ~~~~~^~~~~~~~~ main.cpp:73:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 73 | scanf("%d %d %d %d",&u,&v,&w,&b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:89:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 89 | scanf("%d %d %d",&u,&v,&w); | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 100000000000000000 using A = array<mint,5>; A op(A a,A b){ rep(i,5){ a[i] += b[i]; } return a; } A e(){ A ret; rep(i,5)ret[i] = 0; return ret; } A mapping(int a,A b){ if(a==-1)return b; mint t = 1; rep(i,5){ b[i] = b[0] * t; t *= a; } return b; } int composition(int a,int b){ if(a==-1)return b; if(b==-1)return a; return a; } int id(){ return -1; } int main(){ int N; cin>>N; vector<A> AA(N); rep(i,N){ int t; scanf("%d",&t); mint cur = 1; rep(j,5){ AA[i][j] = cur; cur *= t; } } lazy_segtree<A,op,e,int,mapping,composition,id> seg(AA); int Q; cin>>Q; rep(_,Q){ int t; scanf("%d",&t); if(t==0){ int u,v,w,b; scanf("%d %d %d %d",&u,&v,&w,&b); u--;v--;w--; if(u>v)swap(u,v); vector<int> l,r; if(u<w&&w<v)l.push_back(u),r.push_back(v+1); else{ l.push_back(0),r.push_back(u+1); l.push_back(v),r.push_back(N); } rep(j,l.size()){ seg.apply(l[j],r[j],b); } } else{ mint ans = 0; int u,v,w; scanf("%d %d %d",&u,&v,&w); u--;v--;w--; if(u>v)swap(u,v); vector<int> l,r; if(u<w&&w<v)l.push_back(u),r.push_back(v+1); else{ l.push_back(0),r.push_back(u+1); l.push_back(v),r.push_back(N); } A ret = e(); rep(j,l.size()){ ret = op(ret,seg.prod(l[j],r[j])); } mint M = ret[1]; M /= ret[0]; if(t==1){ ans += ret[1]; ans -= M * ret[0]; } if(t==2){ ans += ret[2]; ans -= M * ret[1] * 2; ans += M * M * ret[0]; } if(t==3){ ans += ret[3]; ans -= M * ret[2] * 3; ans += M * M * ret[1] * 3; ans -= M * M * M * ret[0]; } if(t==4){ ans += ret[4]; ans -= ret[3] * M * 4; ans += M * M * ret[2] * 6; ans -= M * M * M * ret[1] * 4; ans += M * M *M * M * ret[0]; } ans /= ret[0]; printf("%d\n",ans.val()); } } return 0; }