結果

問題 No.1958 Bit Game
ユーザー 沙耶花沙耶花
提出日時 2022-05-27 21:27:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 5,967 ms
コンパイル使用メモリ 263,532 KB
実行使用メモリ 5,436 KB
最終ジャッジ日時 2023-10-20 19:52:31
合計ジャッジ時間 16,084 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 395 ms
5,436 KB
testcase_01 AC 406 ms
5,436 KB
testcase_02 AC 404 ms
5,436 KB
testcase_03 AC 402 ms
5,436 KB
testcase_04 AC 405 ms
5,436 KB
testcase_05 AC 408 ms
5,436 KB
testcase_06 AC 408 ms
5,436 KB
testcase_07 AC 389 ms
5,436 KB
testcase_08 AC 393 ms
5,436 KB
testcase_09 AC 401 ms
5,436 KB
testcase_10 AC 110 ms
4,348 KB
testcase_11 AC 199 ms
4,380 KB
testcase_12 AC 203 ms
4,644 KB
testcase_13 AC 251 ms
4,380 KB
testcase_14 AC 227 ms
4,380 KB
testcase_15 AC 168 ms
4,908 KB
testcase_16 AC 108 ms
4,380 KB
testcase_17 AC 325 ms
5,172 KB
testcase_18 AC 282 ms
4,908 KB
testcase_19 AC 149 ms
4,644 KB
testcase_20 AC 300 ms
4,380 KB
testcase_21 AC 206 ms
4,908 KB
testcase_22 AC 160 ms
4,348 KB
testcase_23 AC 104 ms
4,348 KB
testcase_24 AC 326 ms
4,644 KB
testcase_25 AC 139 ms
4,348 KB
testcase_26 AC 271 ms
4,380 KB
testcase_27 AC 150 ms
4,644 KB
testcase_28 AC 303 ms
4,644 KB
testcase_29 AC 164 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

mint get(int n,vector<int> c0,vector<int> c1){
	vector<mint> dp(2,0);
	dp[0] = 1;
	rep(i,n){
		{
			vector<mint> ndp(2,0);
			rep(j,2){
				rep(k,2){
					ndp[j|k] += dp[j] * c0[k];
				}
			}
			swap(dp,ndp);
		}
		{
			vector<mint> ndp(2,0);
			rep(j,2){
				rep(k,2){
					ndp[j&k] += dp[j] * c1[k];
				}
			}
			swap(dp,ndp);
		}
	}
	return dp[1];
}
		
	


int main(){
	
	int n,x,y;
	cin>>n>>x>>y;
	vector<int> a(x),b(y);
	rep(i,x)cin>>a[i];
	rep(i,y)cin>>b[i];
	
	mint ans =0 ;
	
	rep(i,18){
		vector c0(2,0),c1(2,0);
		rep(j,x){
			if((a[j]>>i)&1)c0[1]++;
			else c0[0]++;
		}
		rep(j,y){
			if((b[j]>>i)&1)c1[1]++;
			else c1[0]++;
		}
		mint g = get(n,c0,c1);
		g *= mint(2).pow(i);
		ans += g;
	}
	cout<<ans.val()<<endl;
	
	
	return 0;
}
0