結果
| 問題 |
No.2344 (l+r)^2
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2023-06-10 14:30:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 2,000 ms |
| コード長 | 1,970 bytes |
| コンパイル時間 | 808 ms |
| コンパイル使用メモリ | 79,416 KB |
| 最終ジャッジ日時 | 2025-02-14 01:17:05 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 |
ソースコード
#line 1 "..\\Main.cpp"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
#line 4 "D:\\Programming\\VSCode\\competitive-cpp\\nachia\\misc\\bit-operations.hpp"
namespace nachia{
int Popcount(unsigned long long c) noexcept {
#ifdef __GNUC__
return __builtin_popcountll(c);
#else
c = (c & (~0ull/3)) + ((c >> 1) & (~0ull/3));
c = (c & (~0ull/5)) + ((c >> 2) & (~0ull/5));
c = (c & (~0ull/17)) + ((c >> 4) & (~0ull/17));
c = (c * (~0ull/257)) >> 56;
return c;
#endif
}
// please ensure x != 0
int MsbIndex(unsigned long long x) noexcept {
#ifdef __GNUC__
return 63 - __builtin_clzll(x);
#else
int res = 0;
for(int d=32; d>0; d>>=1) if(x >> d){ res |= d; x >>= d; }
return res;
#endif
}
// please ensure x != 0
int LsbIndex(unsigned long long x) noexcept {
#ifdef __GNUC__
return __builtin_ctzll(x);
#else
return MsbIndex(x & -x);
#endif
}
}
#line 7 "..\\Main.cpp"
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;
int main(){
int T; cin >> T;
rep(t,T){
int N; cin >> N;
int M; cin >> M;
vector<i64> A(N); rep(i,N) cin >> A[i];
if(M+1 <= N){
vector<i64> B(M+1);
rep(s,M+1) rep(t,N-M) if(((N-M-1) & t) == t){
B[s] ^= A[s+t] & 1;
}
N = B.size();
A = B;
}
while(N > 1){
rep(i,N-1){
A[i] = (A[i] + A[i+1]) * (A[i] + A[i+1]);
A[i] &= (1ll << M) - 1;
}
N--;
}
cout << A[0] << '\n';
}
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia