QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#78618#4820. Kitten's ComputerAppleblue17AC ✓1ms3572kbC++142.3kb2023-02-19 22:23:162023-02-19 22:23:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-19 22:23:19]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3572kb
  • [2023-02-19 22:23:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=1e5+5;

bool debug=false;

ull Data[N];
int tme[N];

void SET(int i,int j){
	if(!debug) printf("SET %d %d\n",i,j);
	Data[i]=Data[j];
	tme[i]=max({tme[j]})+1;
}
void XOR(int i,int j,int k){
	if(!debug) printf("XOR %d %d %d\n",i,j,k);
	Data[i]=Data[j] ^ Data[k];
	tme[i]=max({tme[j],tme[k]})+1;
}
void AND(int i,int j,int k){
	if(!debug) printf("AND %d %d %d\n",i,j,k);
	Data[i]=Data[j] & Data[k];
	tme[i]=max({tme[j],tme[k]})+1;
}
void OR(int i,int j,int k){
	if(!debug) printf("OR %d %d %d\n",i,j,k);
	Data[i]=Data[j] | Data[k];
	tme[i]=max({tme[j],tme[k]})+1;
}
void NOT(int i,int j){
	if(!debug) printf("NOT %d %d\n",i,j);
	Data[i]=~Data[j];
	tme[i]=max({tme[j]})+1;
}
void LSH(int i,int x){
	if(!debug) printf("LSH %d %d\n",i,x);
	Data[i]<<=x;
	tme[i]++;
}
void RSH(int i,int x){
	if(!debug) printf("RSH %d %d\n",i,x);
	Data[i]>>=x;
	tme[i]++;
}

int cnt;

int G[64],P[64],S[64],tmp=400;
int adder(int x,int y){
	for(int i=0;i<64;i++){
		G[i]=++cnt;
		AND(G[i],x,y);
		
		LSH(G[i],i);
	}
	for(int i=0;i<64;i++){
		P[i]=++cnt;
		XOR(P[i],x,y);
		
		LSH(P[i],i);
	}
	
	for(int t=0;t<6;t++){
		for(int i=0;i<64-(1<<t);i++){
			AND(tmp,G[i+(1<<t)],P[i]);
			OR(G[i],G[i],tmp);
			
			AND(P[i],P[i],P[i+(1<<t)]);
		}
	}
	XOR(1,x,y);
	XOR(1,1,G[1]);
	
	return 1;
}

int A[64],B[64];


int f[2][64],siz[2],id;
void trans(int x,int y,int z,int s,int c){
	XOR(s,x,y);
	XOR(s,s,z);
	
	OR(c,x,y);
	AND(c,c,z);
	AND(x,x,y);
	OR(c,c,x);
	
	LSH(c,1);
}

int main(){
	cnt=2;
	for(int i=0;i<64;i++) B[i]=++cnt;
	
	int sav=cnt;
	for(int i=0;i<64;i++){
		cnt=sav;
		for(int j=0;j<64;j++){
			A[j]=++cnt;
			SET(A[j],2);
			LSH(A[j],63-i);
			RSH(A[j],63);
			LSH(A[j],j);
		}
		for(int t=0;t<6;t++){
			for(int j=0;j+(1<<t)<64;j+=(1<<t)){
				OR(A[j],A[j],A[j+(1<<t)]);
			}
		}
		AND(B[i],A[0],1);
		LSH(B[i],i);
	}
	cnt=sav;
	
	for(int i=0;i<64;i++) f[0][i+1]=B[i];
	siz[0]=64;
	
	while(siz[id]>2){
		id^=1;
		siz[id]=0;
		for(int t=1;t<=siz[id^1]%3;t++){
			f[id][++siz[id]]=f[id^1][t];
		}
		for(int t=siz[id^1]%3+1;t<=siz[id^1];t+=3){
			f[id][++siz[id]]=++cnt;
			f[id][++siz[id]]=++cnt;
			trans(f[id^1][t],f[id^1][t+1],f[id^1][t+2],cnt-1,cnt);
		}
	}
	
	adder(f[id][1],f[id][2]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

main

output:

SET 67 2
LSH 67 63
RSH 67 63
LSH 67 0
SET 68 2
LSH 68 63
RSH 68 63
LSH 68 1
SET 69 2
LSH 69 63
RSH 69 63
LSH 69 2
SET 70 2
LSH 70 63
RSH 70 63
LSH 70 3
SET 71 2
LSH 71 63
RSH 71 63
LSH 71 4
SET 72 2
LSH 72 63
RSH 72 63
LSH 72 5
SET 73 2
LSH 73 63
RSH 73 63
LSH 73 6
SET 74 2
LSH 74 63
RSH 74 63
LSH 7...

result:

ok Correct: depth=63