QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#85944#4820. Kitten's Computer_UMqwq_AC ✓0ms3616kbC++201.5kb2023-03-08 21:34:422023-03-08 21:34:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-08 21:34:44]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3616kb
  • [2023-03-08 21:34:42]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
int t[410];
void assign(int i,int j){t[i]=t[j]+1;printf("SET %lld %lld\n",i,j);}
void lsh(int i,int x){t[i]++;printf("LSH %lld %lld\n",i,x);}
void rsh(int i,int x){t[i]++;printf("RSH %lld %lld\n",i,x);}
void getxor(int i,int j,int k){t[i]=max(t[j],t[k])+1;printf("XOR %lld %lld %lld\n",i,j,k);}
void getand(int i,int j,int k){t[i]=max(t[j],t[k])+1;printf("AND %lld %lld %lld\n",i,j,k);}
void reduce(int i,int j,int k){
	getxor(1,i,j);getand(2,i,j);
	getxor(i,1,k);getand(k,1,k);
	getxor(j,2,k);lsh(j,1);
}
void add(int i,int j,int k){
	getxor(1,j,k);getand(2,j,k);
	for(int t=0;t<6;t++){
		assign(3,2);lsh(2,1<<t);getand(2,1,2);getxor(2,2,3);
		assign(3,1);lsh(1,1<<t);getand(1,1,3);
	}
	getxor(1,j,k);lsh(2,1);getxor(i,1,2);
}
set<pii>s;
signed main(){
	for(int i=0;i<64;i++){
		assign(3,1);lsh(3,63-i);rsh(3,63);
		for(int j=0;j<6;j++)
			assign(4,3),lsh(3,1<<j),getxor(3,3,4);
		assign(4,2);lsh(4,i);getand(i+5,3,4);
		s.insert(mp(t[i+5],i+5));
	}
	//mul(1,2)->add([5,68])
	while(s.size()>2u){
		int i=s.begin()->se;s.erase(s.begin());
		int j=s.begin()->se;s.erase(s.begin());
		int k=s.begin()->se;s.erase(s.begin());
		reduce(i,j,k);
		s.insert(mp(t[i],i));s.insert(mp(t[j],j));
	}
	int i=s.begin()->se;s.erase(s.begin());
	int j=s.begin()->se;s.erase(s.begin());
	add(1,i,j);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

main

output:

SET 3 1
LSH 3 63
RSH 3 63
SET 4 3
LSH 3 1
XOR 3 3 4
SET 4 3
LSH 3 2
XOR 3 3 4
SET 4 3
LSH 3 4
XOR 3 3 4
SET 4 3
LSH 3 8
XOR 3 3 4
SET 4 3
LSH 3 16
XOR 3 3 4
SET 4 3
LSH 3 32
XOR 3 3 4
SET 4 2
LSH 4 0
AND 5 3 4
SET 3 1
LSH 3 62
RSH 3 63
SET 4 3
LSH 3 1
XOR 3 3 4
SET 4 3
LSH 3 2
XOR 3 3 4
SET 4 3
LSH ...

result:

ok Correct: depth=65