結果
問題 | No.2833 Count Taiko Results |
ユーザー | ぷら |
提出日時 | 2024-08-02 22:16:11 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,747 bytes |
コンパイル時間 | 1,563 ms |
コンパイル使用メモリ | 141,496 KB |
実行使用メモリ | 8,832 KB |
最終ジャッジ日時 | 2024-08-02 22:16:17 |
合計ジャッジ時間 | 6,279 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | WA | - |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | WA | - |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 66 ms
7,168 KB |
testcase_37 | WA | - |
testcase_38 | AC | 39 ms
6,144 KB |
testcase_39 | AC | 55 ms
7,552 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 79 ms
8,704 KB |
testcase_53 | WA | - |
testcase_54 | AC | 2 ms
5,376 KB |
testcase_55 | AC | 55 ms
8,704 KB |
testcase_56 | AC | 55 ms
8,576 KB |
testcase_57 | AC | 55 ms
8,704 KB |
ソースコード
#include <string.h> #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template <typename T> using vc = vector<T>; template <typename T> using vvc = vector<vector<T>>; template <typename T> using vvvc = vector<vector<vector<T>>>; template<class T> using pq = priority_queue<T,vector<T>,greater<T>>; template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); } template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); } int dx4[] = {1,0,-1,0}; int dy4[] = {0,1,0,-1}; #define overload5(a, b, c, d, e, name, ...) name #define overload4(a, b, c, d, name, ...) name #define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf) #define REP1(i, n) for(ll i = 0; i < (n); ++i) #define REP2(i, a, b) for(ll i = (a); i < (b); ++i) #define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__) #define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf) #define per1(i, n) for(ll i = (n)-1; i >= 0; --i) #define per2(i, a, b) for(ll i = (a)-1; i >= b; --i) #define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c)) #define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__) #define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii)) #define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));) #define fi first #define se second #define pb push_back #define ppb pop_back #define ppf pop_front #define drop(s) cout << #s << endl, exit(0) #define si(c) (int)(c).size() #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{})) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{})) #define rng(v, l, r) v.begin() + (l), v.begin() + (r) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define SORT(v) sort(all(v)) #define REV(v) reverse(all(v)) #define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end()) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define overload2(_1, _2, name, ...) name #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) constexpr int mod = 998244353; long long modpow(long long a,long long b) { long long ans = 1; while(b) { if(b & 1) { (ans *= a) %= mod; } (a *= a) %= mod; b /= 2; } return ans; } void mpl(int &x,int y) { x += y; if(x >= mod) x -= mod; } int dp[200200],dp2[200200]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,K; cin >> N >> K; vc<int>A(N),B(N); rep(i,N) { cin >> A[i]; } rep(i,N) { cin >> B[i]; } vc<int>C(N+1),D(N+1),E(N+1); C[0] = D[0] = E[0] = 1; rep(i,N) { C[i+1] = 1ll*C[i]*A[i]%mod; } rep(i,N) { D[i+1] = 1ll*D[i]*B[i]%mod; } rep(i,N) { E[i+1] = 1ll*E[i]*(A[i]+B[i])%mod; } dp[0] = 1; rep(i,N) { mpl(dp[i+1],1ll*dp[i]*(A[i]+B[i])%mod); if(i+K+1 <= N) mpl(dp[i+K+1],mod-1ll*dp[i]*C[i+K]%mod*modpow(C[i],mod-2)%mod); } dp2[N] = 1; per(i,N) { mpl(dp2[i],1ll*dp2[i+1]*(A[i]+B[i])%mod); if(i-K-1 >= 0) mpl(dp2[i-K-1],mod-1ll*dp2[i+1]*C[i+1]%mod*modpow(C[i-K],mod-2)%mod); } int fans = 0; rep(i,N) { int ans = 1; if(i) { ans = 1ll*ans*dp[i-1]%mod; ans = 1ll*ans*B[i-1]%mod; } if(i+K == N) { ans = 1ll*ans*C[i+K]%mod*modpow(C[i],mod-2)%mod; mpl(fans,ans); } if(i+K < N) { ans = 1ll*ans*C[i+K]%mod*modpow(C[i],mod-2)%mod; ans = 1ll*ans*B[i+K]%mod; ans = 1ll*ans*dp2[i+K+1]%mod; mpl(fans,ans); } } cout << fans << "\n"; }