結果

問題 No.2164 Equal Balls
ユーザー t98slidert98slider
提出日時 2022-12-15 04:23:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,034 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 107,944 KB
最終ジャッジ日時 2024-04-27 04:23:54
合計ジャッジ時間 1,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:7:10: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
    7 |     ios::sync_with_stdio(false);
      |          ^~~~~~~~~~~~~~~
main.cpp:8:5: error: 'cin' was not declared in this scope
    8 |     cin.tie(0);
      |     ^~~
main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include <atcoder/all>
  +++ |+#include <iostream>
    2 | using namespace std;
main.cpp:29:5: error: 'cout' was not declared in this scope
   29 |     cout << accumulate(tb.begin(), tb.end(), vector<mint>(1, 1), [](vector<mint> lhs, vector<mint> rhs){
      |     ^~~~
main.cpp:29:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, r = 600;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for(auto &&v:A)cin >> v;
    for(auto &&v:B)cin >> v;

    vector<vector<mint>> comb(r + 1), tb(M, vector<mint>(r + 1, 1));
    for(int i = 1; i <= r; i++){
        comb[i].resize(i + 1);
        comb[i][0] = comb[i][i] = 1;
        for(int j = 1; j < i; j++) comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
    }

    for(int i = 0, rem = 0; i < N; i++){
        for(int j = -B[i]; j <= A[i]; j++) tb[rem][j + 300] *= comb[A[i] + B[i]][B[i] + j];
        for(int j = A[i] + 1; j <= 300; j++) tb[rem][j + 300] = 0;
        for(int j = B[i] + 1; j <= 300; j++) tb[rem][-j + 300] = 0;
        if(++rem >= M)rem -= M;
    }

    cout << accumulate(tb.begin(), tb.end(), vector<mint>(1, 1), [](vector<mint> lhs, vector<mint> rhs){
        return convolution(lhs, rhs);
    })[300 * M].val() << '\n';
}
0