結果

問題 No.1958 Bit Game
ユーザー 👑 kmjpkmjp
提出日時 2022-05-27 22:57:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 202,712 KB
実行使用メモリ 10,360 KB
最終ジャッジ日時 2023-10-20 20:36:04
合計ジャッジ時間 5,945 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
10,360 KB
testcase_01 AC 110 ms
10,360 KB
testcase_02 AC 110 ms
10,360 KB
testcase_03 AC 111 ms
10,360 KB
testcase_04 AC 111 ms
10,360 KB
testcase_05 AC 111 ms
10,360 KB
testcase_06 AC 111 ms
10,360 KB
testcase_07 AC 111 ms
10,360 KB
testcase_08 AC 111 ms
10,360 KB
testcase_09 AC 111 ms
10,360 KB
testcase_10 AC 31 ms
5,932 KB
testcase_11 AC 55 ms
5,912 KB
testcase_12 AC 61 ms
8,312 KB
testcase_13 AC 67 ms
8,312 KB
testcase_14 AC 61 ms
6,024 KB
testcase_15 AC 55 ms
8,288 KB
testcase_16 AC 35 ms
6,196 KB
testcase_17 AC 92 ms
10,360 KB
testcase_18 AC 82 ms
10,360 KB
testcase_19 AC 46 ms
8,020 KB
testcase_20 AC 75 ms
6,232 KB
testcase_21 AC 62 ms
8,224 KB
testcase_22 AC 41 ms
5,960 KB
testcase_23 AC 32 ms
6,136 KB
testcase_24 AC 88 ms
8,312 KB
testcase_25 AC 40 ms
6,020 KB
testcase_26 AC 69 ms
7,808 KB
testcase_27 AC 48 ms
8,232 KB
testcase_28 AC 81 ms
8,312 KB
testcase_29 AC 44 ms
5,596 KB
testcase_30 AC 2 ms
5,540 KB
testcase_31 AC 3 ms
5,592 KB
testcase_32 AC 2 ms
5,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


int N,X,Y;
int A[1<<20],B[1<<20];
const ll mo=998244353;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X>>Y;
	FOR(i,X) cin>>A[i];
	FOR(i,Y) cin>>B[i];
	ll ret=0;
	FOR(i,18) {
		int C[2]={},D[2]={};
		FOR(j,X) C[(A[j]>>i)&1]++;
		FOR(j,Y) D[(B[j]>>i)&1]++;
		
		ll from[2]={1,0};
		FOR(j,N) {
			ll to[2]={};
			to[0]=from[0]*C[0]%mo;
			to[1]=(from[1]*C[0]+from[0]*C[1]+from[1]*C[1])%mo;
			from[1]=to[1]*D[1]%mo;
			from[0]=(to[1]*D[0]+to[0]*D[1]+to[0]*D[0])%mo;
		}
		
		ret+=(1<<i)*from[1]%mo;
		
	}
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0