結果

問題 No.2561 みんな大好きmod 998
ユーザー VvyLwVvyLw
提出日時 2023-12-02 17:32:41
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,467 bytes
コンパイル時間 1,863 ms
コンパイル使用メモリ 107,064 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 17:32:50
合計ジャッジ時間 9,600 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 516 ms
6,676 KB
testcase_05 AC 488 ms
6,676 KB
testcase_06 WA -
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 77 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 WA -
testcase_16 AC 5 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 WA -
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 3 ms
6,676 KB
testcase_26 AC 164 ms
6,676 KB
testcase_27 AC 489 ms
6,676 KB
testcase_28 AC 322 ms
6,676 KB
testcase_29 AC 17 ms
6,676 KB
testcase_30 AC 17 ms
6,676 KB
testcase_31 AC 93 ms
6,676 KB
testcase_32 AC 502 ms
6,676 KB
testcase_33 AC 18 ms
6,676 KB
testcase_34 AC 494 ms
6,676 KB
testcase_35 AC 163 ms
6,676 KB
testcase_36 AC 191 ms
6,676 KB
testcase_37 AC 26 ms
6,676 KB
testcase_38 AC 77 ms
6,676 KB
testcase_39 AC 17 ms
6,676 KB
testcase_40 AC 17 ms
6,676 KB
testcase_41 AC 77 ms
6,676 KB
testcase_42 AC 322 ms
6,676 KB
testcase_43 AC 26 ms
6,676 KB
testcase_44 AC 37 ms
6,676 KB
testcase_45 AC 214 ms
6,676 KB
testcase_46 AC 314 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
#include <numeric>
int main() {
  int n, k, cnt = 0;
  std::cin >> n >> k;
  std::vector<int> a(n);
  for(auto &el: a) {
    std::cin >> el;
  }
  std::vector<std::vector<int>> pat, ano;
  for(int i = 0; i < 1 << (n / 2); ++i) {
    std::vector<int> x;
    for(int j = 0; j < n / 2; ++j) {
      if(i >> j & 1) {
        x.emplace_back(a[j]);
      }
    }
    if(std::ssize(x) == k) pat.emplace_back(x);
    /*if(std::ssize(x) == k) {
      const auto res = std::accumulate(x.begin(), x.end(), 0LL);
      if(res % 998 >= res % 998244353) {
        cnt++;
        cnt %= 998;
      }
    }//*/
  }
  for(int i = 0; i < 1 << (n - n / 2); ++i) {
    std::vector<int> x;
    for(int j = 0; j < n - n / 2; ++j) {
      if(i >> j & 1) {
        x.emplace_back(a[n / 2 + j]);
      }
    }
    if(std::ssize(x) == k) ano.emplace_back(x);
    /* {
      const auto res = std::accumulate(x.begin(), x.end(), 0LL);
      if(res % 998 >= res % 998244353) {
        cnt++;
        cnt %= 998;
      }
    }//*/
  }
  for(const auto &l: pat) {
    for(const auto &r: ano) {
      auto v = l;
      v.insert(v.end(), r.cbegin(), r.cend());
      if(std::ssize(v) == k) {
        const auto res = std::accumulate(v.begin(), v.end(), 0LL);
        if(res % 998 >= res % 998244353) {
          cnt++;
          cnt %= 998;
        }
      }
    }
  }
  std::cout << cnt << '\n';
}
0