QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#73400#4820. Kitten's ComputerJerryTclWA 3ms3480kbC++142.8kb2023-01-25 00:01:042023-01-25 00:01:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-25 00:01:07]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3480kb
  • [2023-01-25 00:01:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define fi first
#define se second
typedef int Rg;
const int W = 64;
const Rg in0 = 1, in1 = 2, out = 1, zero = 3, bg = 4;
void Set(Rg out, Rg in) { printf("SET %d %d\n", out, in); }
void Xor(Rg out, Rg in0, Rg in1) { printf("XOR %d %d %d\n", out, in0, in1); }
void And(Rg out, Rg in0, Rg in1) { printf("AND %d %d %d\n", out, in0, in1); }
void Or(Rg out, Rg in0, Rg in1) { printf("OR %d %d %d\n", out, in0, in1); }
void Lsh(Rg io, int k) { printf("LSH %d %d\n", io, k); }
void Rsh(Rg io, int k) { printf("RSH %d %d\n", io, k); }
void Get(Rg io, int k) { Lsh(io, W - k - 1), Rsh(io, W - 1); }
void Fill(Rg io, Rg h[3]) {
	const Rg h0 = h[0], h1 = h[1], h2 = h[2];
	Set(h0, io), Set(h1, io), Set(h2, io);
	Lsh(h0, 1), Lsh(h1, 2), Lsh(h2, 3);
	Or(io, io, h0), Or(h1, h1, h2), Or(io, io, h1);
	Set(h0, io), Set(h1, io), Set(h2, io);
	Lsh(h0, 4), Lsh(h1, 8), Lsh(h2, 12);
	Or(io, io, h0), Or(h1, h1, h2), Or(io, io, h1);
	Set(h0, io), Set(h1, io), Set(h2, io);
	Lsh(h0, 16), Lsh(h1, 32), Lsh(h2, 48);
	Or(io, io, h0), Or(h1, h1, h2), Or(io, io, h1);
}
void Mul(Rg in0, Rg in1, Rg out[64], Rg h[256]) {
	for(int i = 0; i < W; ++i) {
		Rg *const hp = h + i * 4;
		Set(out[i], in0), Lsh(out[i], i);
		Set(hp[0], in1), Get(hp[0], i);
		Fill(hp[0], hp + 1);
		And(out[i], out[i], hp[i]);
	}
}
void Add(Rg in0, Rg in1, Rg out, Rg h[128]) {
	Rg *const h0 = h, *const h1 = h + 64;
	h0[0] = out, And(h0[0], in0, in1), Xor(h1[0], in0, in1);
	for(int i = 1; i < W - 1; ++i) Set(h0[i], h0[0]), Lsh(h0[i], i + 1);
	for(int i = 1; i < W - 1; ++i) Set(h1[i], h1[0]), Lsh(h1[i], i + 1);
	Set(h0[W - 1], zero), Set(h1[W - 1], zero);
	Lsh(h0[0], 1), Xor(h0[0], h0[0], h1[0]), Lsh(h1[0], 1);
	for(int l = 1; l < W; l <<= 1)
		for(int i = 0; i < W; i += (l << 1))
			for(int j = l; j < (l << 1); ++j)
				And(h1[i + j], h1[i + l - 1], h1[i + j]);
	for(int i = 1; i < W; ++i) And(h0[i], h0[i], h1[i - 1]);
	for(int l = 1; l < W; l <<= 1)
		for(int i = 0; i < W; i += (l << 1)) Xor(h0[i], h0[i], h0[i + l]);
}
void Add3(Rg io0, Rg io1, Rg in2, Rg h[2]) {
	const Rg h0 = h[0], h1 = h[1];
	Xor(h0, io0, io1), And(h1, io0, io1);
	And(io1, in2, h0), Xor(io1, io1, h1);
	Xor(io0, in2, h0), Lsh(io1, 1);
}
int main() {
	Rg h[W * 5], a0, a1, a2, *a = h + W * 4; int d;
	for(int i = 0; i < W * 5; ++i) h[i] = bg + i;
	Mul(in0, in1, a, h);
	priority_queue<pii, vector<pii>, greater<pii>> Q;
	for(int i = 0; i < W; ++i) Q.emplace(0, a[i]);
	for(int i = 0; i < W - 2; ++i) {
		a0 = Q.top().se, Q.pop(), a1 = Q.top().se, Q.pop();
		a2 = Q.top().se, d = Q.top().fi, Q.pop();
		Add3(a0, a1, a2, h + i * 2);
		Q.emplace(d + 2, a0), Q.emplace(d + 4, a1);
	}
	a0 = Q.top().se, Q.pop(), a1 = Q.top().se, Add(a0, a1, out, h);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3480kb

input:

main

output:

SET 260 1
LSH 260 0
SET 4 2
LSH 4 63
RSH 4 63
SET 5 4
SET 6 4
SET 7 4
LSH 5 1
LSH 6 2
LSH 7 3
OR 4 4 5
OR 6 6 7
OR 4 4 6
SET 5 4
SET 6 4
SET 7 4
LSH 5 4
LSH 6 8
LSH 7 12
OR 4 4 5
OR 6 6 7
OR 4 4 6
SET 5 4
SET 6 4
SET 7 4
LSH 5 16
LSH 6 32
LSH 7 48
OR 4 4 5
OR 6 6 7
OR 4 4 6
AND 260 260 4
SET 261 1
L...

result:

wrong answer Wrong Answer on test 1: a[1]=2839929338295232408, a[2]=10943642511305433214, but found 15632226026675240960