結果
| 問題 | No.3594 Subset OR |
| ユーザー |
|
| 提出日時 | 2026-07-23 22:23:21 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 544 ms / 3,000 ms |
| + 237µs | |
| コード長 | 1,807 bytes |
| 記録 | |
| コンパイル時間 | 2,693 ms |
| コンパイル使用メモリ | 228,732 KB |
| 実行使用メモリ | 134,784 KB |
| 最終ジャッジ日時 | 2026-07-23 22:24:19 |
| 合計ジャッジ時間 | 27,442 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#pragma GCC optimize("O3")
#include <iterator>
#pragma GCC target("avx2")
#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(),x.end()
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#define ASSERT(...) 42
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int oo = 1e9;
const int N = 1<<30;
const int B = 64;
const int K = N/B;
typedef unsigned long long ull;
ull x[K];
char ans[1<<16];
int calc4(ull x) {
return ans[x];
}
int calc2(ull x) {
ull y = x>>(B/4);
return calc4(y) + calc4((x|y) &( (1ULL<<(B/4)) - 1) );
}
int calc(ull x) {
ull y = x>>(B/2);
return calc2((x|y)&( (1ULL<<(B/2)) - 1))+calc2(y);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n; cin >> n;
for(int i=0;i<1<<16;++i) {
bool b[16] = {};
for(int j=0;j<16;++j) b[j] = i>>j&1;
for(int j=0;j<4;++j) {
for(int x=0;x<16;++x) if(!(1<<j & x)) {
b[x]|=b[x|1<<j];
}
}
for(int j=0;j<16;++j) ans[i]+=b[j];
}
while(n--) {
int a; cin >> a;
x[a/B]|=1ULL<<(a%B);
}
for(int j=0;(1<<j)<K;++j) {
for(int i=0;i<K;++i) if(!(1<<j & i)) {
x[i]|=x[i|1<<j];
}
}
int res=0;
for(int i=0;i<K;++i) {
res+=calc(x[i]);
}
cout << res << '\n';
}