結果
| 問題 |
No.2171 OR Assignment
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-12-23 01:19:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,942 ms / 3,500 ms |
| コード長 | 1,232 bytes |
| コンパイル時間 | 3,834 ms |
| コンパイル使用メモリ | 261,524 KB |
| 最終ジャッジ日時 | 2025-02-09 18:50:03 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#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];
vector<pair<int,long long>> mp;
mp.emplace_back(a[0],1);
for(int i=1;i<n;i++){
vector<pair<int,long long>> nmp;
for(auto b:mp)nmp.emplace_back(b.first|a[i],0LL);
sort(nmp.begin(),nmp.end());
nmp.erase(unique(nmp.begin(),nmp.end()),nmp.end());
if(binary_search(nmp.begin(),nmp.end(),make_pair(a[i],0LL))){
nmp.erase(find(nmp.begin(),nmp.end(),make_pair(a[i],0LL)));
}
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){
c.second += b.second;
c.second %= 998244353;
}
}
}
nmp.insert(nmp.begin(),make_pair(a[i],0));
for(auto b:mp){
nmp[0].second += b.second;
nmp[0].second %= 998244353;
}
swap(mp,nmp);
}
mint ans = 0;
for(auto b:mp)ans += b.second;
cout<<ans.val()<<endl;
return 0;
}
沙耶花