結果
問題 | No.2561 みんな大好きmod 998 |
ユーザー |
|
提出日時 | 2023-12-02 17:34:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,467 bytes |
コンパイル時間 | 1,632 ms |
コンパイル使用メモリ | 107,492 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-09-26 21:15:17 |
合計ジャッジ時間 | 6,911 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 43 |
ソースコード
#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'; }