QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#48689#1083. Belarusian State Universityfeecle6418WA 2ms3696kbC++142.7kb2022-09-15 11:08:152022-09-15 11:08:17

Judging History

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

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

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
const int mod=1e9+7;
int n,tp[20];
__int128 a[270005],b[270005];
string s[20];
//0:and 1:or 2:xor
void FWT(__int128 a[]){
	for(int i=0;i<n;i++){
		for(int j=0;j<(1<<n);j++){
			if(j&(1<<i))continue;
			int x=j,y=j+(1<<i);
			if(tp[i]==0)a[x]+=a[y];
			if(tp[i]==1)a[y]+=a[x];
			if(tp[i]==2){
				__int128 u=a[x]+a[y],v=a[x]-a[y];
				a[x]=u,a[y]=v;
			}
		}
	}
}
void iFWT(__int128 a[]){
	for(int i=0;i<n;i++){
		for(int j=0;j<(1<<n);j++){
			if(j&(1<<i))continue;
			int x=j,y=j+(1<<i);
			if(tp[i]==0)a[x]-=a[y];
			if(tp[i]==1)a[y]-=a[x];
			if(tp[i]==2){
				__int128 u=a[x]+a[y],v=a[x]-a[y];
				a[x]=u/2,a[y]=v/2;
			}
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0,x;i<(1<<n);i++)scanf("%d",&x),a[i]=x;
	for(int i=0,x;i<(1<<n);i++)scanf("%d",&x),b[i]=x;
	for(int i=0;i<n;i++){
		if(s[i]=="0000"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))a[j-(1<<i)]+=a[j],a[j]=0;
		}
		if(s[i]=="0001")tp[i]=0;
		if(s[i]=="0010"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))swap(b[j],b[j^(1<<i)]);
		}
		if(s[i]=="0011"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))b[j]+=b[j-(1<<i)],b[j-(1<<i)]=0;
		}
		if(s[i]=="0100"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))swap(a[j],a[j^(1<<i)]);
		}
		if(s[i]=="0101"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))a[j]+=a[j-(1<<i)],a[j-(1<<i)]=0;
		}
		if(s[i]=="0110")tp[i]=2;
		if(s[i]=="0111")tp[i]=1;
		if(s[i]=="1000"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++){
				if(j&(1<<i)){
					swap(a[j],a[j^(1<<i)]);
					swap(b[j],b[j^(1<<i)]);
				}
			}
		}
		if(s[i]=="1001"){
			tp[i]=2;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))swap(a[j],a[j^(1<<i)]);
		}
		if(s[i]=="1010"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++)
				if(j&(1<<i)){
					a[j]+=a[j-(1<<i)],a[j-(1<<i)]=0;
					swap(b[j],b[j^(1<<i)]);
				}
		}
		if(s[i]=="1011"){
			tp[i]=1;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))swap(b[j],b[j^(1<<i)]);
		}
		if(s[i]=="1100"){
			tp[i]=0;
			for(int j=0;j<(1<<n);j++)
				if(j&(1<<i)){
					swap(a[j],a[j^(1<<i)]);
					b[j]+=b[j-(1<<i)],b[j-(1<<i)]=0;
				}
		}
		if(s[i]=="1101"){
			tp[i]=1;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))swap(a[j],a[j^(1<<i)]);
		}
		if(s[i]=="1110"){
			tp[i]=1;
			for(int j=0;j<(1<<n);j++)
				if(j&(1<<i)){
					swap(a[j],a[j^(1<<i)]);
					swap(b[j],b[j^(1<<i)]);
				}
		}
		if(s[i]=="1111"){
			tp[i]=1;
			for(int j=0;j<(1<<n);j++)if(j&(1<<i))a[j]+=a[j-(1<<i)],a[j]=0;
		}
	}
	FWT(a),FWT(b);
	for(int i=0;i<(1<<n);i++)a[i]*=b[i];
	iFWT(a);
	for(int i=0;i<(1<<n);i++)cout<<(long long)(a[i])<<' ';
}

詳細信息

Test #1:

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

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: 2ms
memory: 3504kb

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: 2ms
memory: 3508kb

input:

1
0000
142857142 857142857
998244353 1755646

output:

999999998000000001 0 

result:

ok 2 number(s): "999999998000000001 0"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3644kb

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:

622762375026 0 211213240105 0 129972274704 0 42996260349 0 560935378242 0 178586809331 0 130355904111 0 48915646794 0 529567786776 0 191142163833 0 97095393090 0 47038307553 0 480103852247 0 159643252657 0 95871796837 0 53514171218 0 1566581437938 0 549108602539 0 542185856124 0 198361528867 0 17454...

result:

wrong answer 1st numbers differ - expected: '0', found: '622762375026'