結果

問題 No.1549 [Cherry 2nd Tune] BANning Tuple
ユーザー chocoruskchocorusk
提出日時 2021-06-11 21:37:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,638 bytes
コンパイル時間 3,536 ms
コンパイル使用メモリ 195,872 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-21 11:47:16
合計ジャッジ時間 4,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, q; cin>>n>>q;
    using mint=modint998244353;
    vector<mint> v(3001);
    v[0]=1;
    for(int i=1; i<=3000; i++) v[i]=v[i-1]*mint(n-1+i)/mint(i);
    int i0=0;
    map<ll, int> mpl, mpr;
    for(int i=0; i<q; i++){
        ll k;
        int a, b, s, t;
        cin>>k>>a>>b>>s>>t;
        b++;
        if(mpl.find(k)!=mpl.end()){
            int a1=mpl[k], b1=mpr[k];
            if(a1==0){
                i0-=b1;
            }else{
                for(int j=0; j<=3000; j++){
                    if(j>=a1) v[j]+=v[j-a1];
                    if(j>=b1) v[j]-=v[j-b1];
                }
            }
            a=min(a, a1), b=max(b, b1);
        }
        mpl[k]=a, mpr[k]=b;
        if(a==0){
            i0+=b;
        }else{
            for(int j=3000; j>=0; j--){
                if(j+a<=3000) v[j+a]-=v[j];
                if(j+b<=3000) v[j+b]+=v[j];
            }
        }
        mint ans=0;
        for(int j=max(0, s-i0); j<=t-i0; j++) ans+=v[j];
        cout<<ans.val()<<endl;
    }
    return 0;
}
0