結果

問題 No.3528 Happy XOR Candy
コンテスト
ユーザー askr58
提出日時 2026-05-04 21:33:43
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,586 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,507 ms
コンパイル使用メモリ 342,300 KB
実行使用メモリ 15,196 KB
最終ジャッジ日時 2026-05-04 21:33:57
合計ジャッジ時間 8,017 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#include <atcoder/modint>
using mint=atcoder::modint998244353;

struct Combination{
	int n;
	vector<mint> _fact,_factinv;

	Combination(int n):n(n){
		_fact.resize(n+1,1);_factinv.resize(n+1,1);
		for(int i=0;i<n;i++)_fact[i+1]=_fact[i]*(i+1);
		_factinv[n]=_fact[n].inv();
		for(int i=n-1;i>=0;i--)_factinv[i]=_factinv[i+1]*(i+1);
	}
	mint fact(int x){
		return _fact[x];
	}
	mint factinv(int x){	
		return _factinv[x];
	}
	mint C(int x,int y){
		assert(0<=x&&x<=n&&0<=y);
		if(x<y)return 0;
		else return _fact[x]*_factinv[y]*_factinv[x-y];
	};
	mint Cinv(int x,int y){
		assert(0<=x&&x<=n&&0<=y);
		if(x<y)return 0;
		else return _factinv[x]*_fact[y]*_fact[x-y];
	}
	mint P(int x,int y){
		assert(0<=x&&x<=n&&0<=y);
		if(x<y)return 0;
		else return _fact[x]*_factinv[x-y];
	}
	mint Pinv(int x,int y){
		assert(0<=x&&x<=n&&0<=y);
		if(x<y)return 0;
		else return _factinv[x]*_fact[x-y];
	}
	mint frac(int y,int x){
		assert(x!=0);
		if(y==0)return 0;
		else return (_fact[y]*_factinv[y-1]*_factinv[x]*_fact[x-1]);
	}
};
		
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<vector<int>> s(n);
	for(int i=0;i<k;i++){
		int l,x;
		cin>>l>>x;
		for(int j=0;j<l;j++){
			int b;
			cin>>b;
			s[b-1].push_back(x);
		}
	}
	mint ans=0;
	Combination comb(n+k);
	mint c=((mint)2).inv();
	for(int i=0;i<n;i++){
		int m=s[i].size();
		for(int j=0;j<30;j++){
			int cnt=0;
			for(int l=0;l<m;l++)if(s[i][l]>>j&1)cnt++;
			if(cnt>0){
				ans+=(1<<j)*c;
			}
		}
	}
	cout<<ans.val()<<endl;
}
0