結果

問題 No.985 Hadamard
ユーザー chocoruskchocorusk
提出日時 2020-02-11 22:16:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 1,106 bytes
コンパイル時間 5,987 ms
コンパイル使用メモリ 111,980 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 15:59:48
合計ジャッジ時間 6,528 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 243 ms
6,676 KB
testcase_05 AC 122 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 121 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 236 ms
6,676 KB
testcase_14 AC 235 ms
6,676 KB
testcase_15 AC 235 ms
6,676 KB
testcase_16 AC 238 ms
6,676 KB
testcase_17 AC 238 ms
6,676 KB
testcase_18 AC 245 ms
6,676 KB
testcase_19 AC 246 ms
6,676 KB
testcase_20 AC 244 ms
6,676 KB
testcase_21 AC 247 ms
6,676 KB
testcase_22 AC 246 ms
6,676 KB
testcase_23 AC 201 ms
6,676 KB
testcase_24 AC 203 ms
6,676 KB
testcase_25 AC 205 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
void FWT(vector<ll> &v){
	int m=v.size();
	for(int i=1; i<m; i<<=1){
		for(int j=0; j<m; j++){
			if((i&j)==0){
				ll x=v[j], y=v[j^i];
				v[j]=x+y, v[j^i]=x-y;
			}
		}
	}
}
int main()
{
	int n;
    cin>>n;
    vector<ll> c(1<<n);
    for(int i=0; i<(1<<n); i++){
        cin>>c[i];
    }
    FWT(c);
    ll ans=0;
    for(int i=0; i<(1<<n); i++){
        ll l, h; cin>>l>>h;
        if(c[i]>0) ans+=c[i]*h;
        else ans+=c[i]*l;
    }
    ans%=MOD;
    for(int i=0; i<n; i++) (ans*=((MOD+1)/2))%=MOD;
    cout<<ans<<endl;
	return 0;
}
0