結果

問題 No.2344 (l+r)^2
ユーザー t98slidert98slider
提出日時 2023-06-10 18:19:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 168,124 KB
実行使用メモリ 4,528 KB
最終ジャッジ日時 2023-08-30 23:43:18
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 60 ms
4,380 KB
testcase_02 AC 14 ms
4,376 KB
testcase_03 AC 13 ms
4,376 KB
testcase_04 AC 13 ms
4,380 KB
testcase_05 AC 13 ms
4,380 KB
testcase_06 AC 13 ms
4,376 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 33 ms
4,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        int n, m;
        cin >> n >> m;
        vector<ll> a(n);
        for(auto &&v : a) cin >> v;
        ll S = (1 << m) - 1, d = n - m;
        if(n > m){
            vector<ll> b(m);
            for(int i = 0; i < m; i++){
                for(int j = 0; j <= d; j++){
                    b[i] ^= ((d & j) == j ? a[i + j] & 1 : 0);
                }
            }
            swap(a, b);
        }
        while(a.size() >= 2){
            for(int i = 0; i + 1 < a.size(); i++){
                a[i] = (a[i] + a[i + 1]) * (a[i] + a[i + 1]) & S;
            }
            a.pop_back();
        }
        cout << a[0] << '\n';
    }
}
0