QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#44302#1083. Belarusian State UniversityxiaoyaowudiWA 2ms3692kbC++142.4kb2022-08-15 11:37:392022-08-15 11:37:40

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-15 11:37:40]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3692kb
  • [2022-08-15 11:37:39]
  • 提交

answer

#include <iostream>
#include <algorithm>
constexpr int N=18;
constexpr int chg[(1<<3)][2]={{0,0},{0,1},{1,0},{0,0},{0,1},{0,1},{0,1},{0,1}},opc[(1<<3)]={0,0,0,2,0,2,1,2};
//0 for and 2 for or 1 for xor
int st[N<<1],rst[N<<1];
int get_st(int k,int t){
	if(k<8) return chg[k][t];
	else return 1^chg[15^k][t];
}
int get_op(int k){
	if(k<8) return opc[k];
	else return 2-opc[15^k];
}
void fwt(long long *f,int b){
	for(int len=1,i=0;i<b;len<<=1,++i){
		if(get_op(st[i])==0){
			for(int j=0;j<(1<<b);j+=(len<<1)){
				for(int k=0;k<len;++k){
					f[j+k]+=f[j+k+len];
				}
			}
		}
		else if(get_op(st[i])==2){
			for(int j=0;j<(1<<b);j+=(len<<1)){
				for(int k=0;k<len;++k){
					f[j+k+len]+=f[j+k];
				}
			}
		}else{
			for(int j=0;j<(1<<b);j+=(len<<1)){
				for(int k=0;k<len;++k){
					long long t1=f[j+k]+f[j+k+len],t2=f[j+k]-f[j+k+len];
					f[j+k]=t1,f[j+k+len]=t2;
				}
			}
		}
	}
}
void ifwt(long long *f,int b){
	for(int len=(1<<(b-1)),i=b-1;i>=0;len>>=1,--i){
		if(get_op(st[i])==0){
			for(int j=0;j<(1<<b);j+=(len<<1)){
				for(int k=0;k<len;++k){
					f[j+k]-=f[j+k+len];
				}
			}
		}
		else if(get_op(st[i])==2){
			for(int j=0;j<(1<<b);j+=(len<<1)){
				for(int k=0;k<len;++k){
					f[j+k+len]-=f[j+k];
				}
			}
		}else{
			for(int j=0;j<(1<<b);j+=(len<<1)){
				for(int k=0;k<len;++k){
					long long t1=(f[j+k]+f[j+k+len])/2,t2=(f[j+k]-f[j+k+len])/2;
					f[j+k]=t1,f[j+k+len]=t2;
				}
			}
		}
	}
}
long long p1[(1<<N)],p2[(1<<N)];int n;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cin>>n;
	for(int i=0;i<n;++i){
		static char s[10];
		std::cin>>s;
		st[i]=0;
		for(int j=0;j<4;++j) st[i]=(st[i]*2+s[j]-'0');
		std::swap(s[1],s[2]);
		rst[i]=0;
		for(int j=0;j<4;++j) rst[i]=(rst[i]*2+s[j]-'0');
	}
	for(int i=0;i<(1<<n);++i){
		int t=0;
		for(int j=0;j<n;++j) t|=(get_st(rst[j],((i>>j)&1))<<j);
		int cur;
		std::cin>>cur;p1[t]+=cur;
	}
	for(int i=0;i<(1<<n);++i){
		int t=0;
		for(int j=0;j<n;++j) t|=(get_st(st[j],((i>>j)&1))<<j);
		int cur;
		std::cin>>cur;p2[t]+=cur;
	}
	// for(int i=0;i<(1<<n);++i){
	// 	std::cout<<p1[i]<<(" \n"[i==(1<<n)-1]);
	// }
	// for(int i=0;i<(1<<n);++i){
	// 	std::cout<<p2[i]<<(" \n"[i==(1<<n)-1]);
	// }
	fwt(p1,n);fwt(p2,n);
	for(int i=0;i<(1<<n);++i) p1[i]*=p2[i];
	ifwt(p1,n);
	for(int i=0;i<(1<<n);++i){
		std::cout<<p1[i]<<(" \n"[i==(1<<n)-1]);
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3680kb

input:

3
0111 0110 0001
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0

output:

0 0 0 0 0 0 0 1

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

2
1100 1101
2 0 2 1
2 0 2 1

output:

2 4 3 16

result:

ok 4 number(s): "2 4 3 16"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

1
0000
142857142 857142857
998244353 1755646

output:

999999998000000001 0

result:

ok 2 number(s): "999999998000000001 0"

Test #4:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

8
0000 0001 0010 0011 0101 1011 1101 1111
92726 51723 30325 31984 47551 61529 94856 58867 99699 44383 29317 34253 85206 99155 54057 21538 23635 64524 11223 78186 73723 38530 99909 38218 32839 92947 57594 79376 87975 25597 26783 11600 77813 98155 26224 76035 42536 80097 32406 81442 49449 76444 40502 ...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2008949968122 0 631347707836 0 560922365664 ...

result:

ok 256 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 3552kb

input:

9
1011 1011 0111 0110 1000 0000 0001 0100 1011
3 1 3 6 0 3 0 0 2 9 4 4 3 0 4 0 3 2 3 0 0 4 0 0 3 4 0 6 2 2 4 5 0 2 3 3 2 4 4 0 3 1 3 5 3 0 4 4 0 0 5 0 2 1 2 0 3 4 0 4 0 8 3 3 0 4 5 0 2 2 3 4 3 1 1 5 7 0 0 0 2 3 0 2 3 5 0 0 0 4 0 0 2 4 3 2 2 6 0 3 5 2 4 7 5 0 2 5 5 0 6 2 3 0 0 5 1 4 5 8 4 2 3 7 0 4 5...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 512 numbers

Test #6:

score: 0
Accepted
time: 2ms
memory: 3692kb

input:

9
1011 0011 0010 1100 1000 0001 1111 0101 1000
0 0 135 0 87 0 0 0 37 108 65 42 0 37 41 82 0 0 0 72 0 39 0 39 35 0 0 38 34 0 0 0 0 65 36 119 0 51 0 102 0 63 46 42 0 60 0 0 0 0 0 130 0 135 0 59 58 85 0 39 70 115 51 0 0 78 0 0 0 104 0 0 0 69 97 84 0 0 102 111 66 0 0 38 47 0 86 0 0 0 0 92 66 0 0 36 0 13...

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 512 numbers

Test #7:

score: -100
Wrong Answer
time: 2ms
memory: 3488kb

input:

8
0011 0011 0010 0011 1001 0011 0011 0110
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12121085 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2963689896687 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3934398721594 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 95789831757240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 159029483675950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

wrong answer 1st numbers differ - expected: '3934398721594', found: '2963689896687'