QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#555086 | #7932. AND-OR closure | liuhengxi | WA | 0ms | 5688kb | C++14 | 1.4kb | 2024-09-09 19:45:28 | 2024-09-09 19:45:29 |
Judging History
answer
// created: 2024-09-09 19:11:33
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<functional>
#define F(i,l,r) for(int i=(l),i##_end=(r);i<i##_end;++i)
#define I128 //||is_same<T,__int128_t>::value||is_same<T,__uint128_t>::value
using namespace std;
template<typename T>enable_if_t<is_integral<T>::value I128,void> readmain(T &x)
{
bool neg=false;int c=getchar();
for(;!isdigit(c);c=getchar())if(c=='-')neg=true;
for(x=0;isdigit(c);c=getchar())x=(T)(10*x+(c-'0'));
if(neg)x=-x;
}
template<typename T>T& read(T &x){readmain(x);return x;}
template<typename T,typename ...Tr>void read(T &x,Tr&... r){readmain(x);read(r...);}
typedef unsigned long long ull;
constexpr int N=45,NN=(1<<20)+5;
int m,n=40,d[N],h,q;
ull a[N],c[N],e[NN],f[NN],g[NN];
int main()
{
read(m);
F(i,0,n)a[i]=-1;
F(i,0,m)
{
ull b;read(b);
F(j,0,n)if(b>>j&1)a[j]&=b;
}
sort(a,a+n,greater<ull>());
m=0;
F(i,0,n)
{
if(~a[i]&&(!i||a[i]!=a[i-1]))d[i]=m++;
else d[i]=-1;
}
F(i,0,n)if(~d[i])F(j,i,n)if(~d[j]&&((a[i]&a[j])==a[j]))c[d[i]]|=1ull<<d[j];
F(i,0,n=m)a[i]=c[i];
h=min(n>>1,20);
e[q++]=0;
F(i,0,h)F(j,0,q)if(~e[j]>>i&1)e[q++]=e[j]|c[i];
F(i,0,q)++f[e[i]>>h];
F(i,h,n)
{
e[i]>>=i+1;
F(j,0,1<<(n-i-1))g[j]+=f[2*j]+f[2*j+1],g[j|e[i]]+=f[2*j];
memcpy(f,g,sizeof(ull)<<(n-i-1));
memset(g,0,sizeof(ull)<<(n-i-1));
}
printf("%llu\n",f[0]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5572kb
input:
4 0 1 3 5
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5588kb
input:
5 0 1 2 3 4
output:
8
result:
ok 1 number(s): "8"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 5688kb
input:
49 1097363587067 1096810445814 275012137504 1096739142630 1096809921522 1087071335264 829364908576 949625500192 1087142638448 1096200190829 1097292808175 1095750860656 1087144145776 1097346808827 1095734082416 1096755396578 829230678048 1095663303524 1087072842592 1096216444777 949623992864 10962714...
output:
45
result:
wrong answer 1st numbers differ - expected: '52', found: '45'