結果

問題 No.2171 OR Assignment
ユーザー 沙耶花
提出日時 2022-12-23 01:12:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 888 bytes
コンパイル時間 3,727 ms
コンパイル使用メモリ 259,744 KB
最終ジャッジ日時 2025-02-09 18:49:13
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 TLE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

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



int main(){
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	
	map<int,mint> mp;
	mp[a[0]] = 1;
	
	for(int i=1;i<n;i++){
		map<int,mint> nmp;
		
		for(auto b:mp)nmp[b.first|a[i]] = 0;
		if(nmp.count(a[i]))nmp.erase(a[i]);
		for(auto b:mp){
			for(auto c:nmp){
				bool f = false;
				for(auto d:mp){
					if((a[i] | d.first) == c.first && (b.first | d.first) == b.first){
						f = true;
						break;
					}
				}
				if(f){
					nmp[c.first] += b.second;
				}
			}
		}
		for(auto b:mp)nmp[a[i]] += b.second;
		
		swap(mp,nmp);
	}
	
	mint ans = 0;
	for(auto b:mp)ans += b.second;
	
	cout<<ans.val()<<endl;
	
	
	return 0;
}
0