QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637956#7747. MemoryShwStoneWA 0ms3764kbC++14756b2024-10-13 14:28:192024-10-13 14:28:22

Judging History

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

  • [2024-10-13 14:28:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3764kb
  • [2024-10-13 14:28:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int MAXN(2e5 + 5);

int n;
int cnt[MAXN], d[MAXN];

int main() {
	scanf("%d", &n);
	int pre = 0;
	for (int i = 1; i <= n; i++) {
		int x, c = 1;
		scanf("%d", &x);

		if (x < 0) x = -x, c = -1;
		for (int j = 0; j < 32; j++) {
			cnt[i + j] += c * ((x >> j) & 1);
		}

		int cc = pre, dd = d[i - 1];

		for (int j = 0; j < 32; j++) {
			if (dd % 2) cc = dd % 2;
			dd = cnt[i + j] + dd / 2;
		}

		if (dd > 0) putchar('+');
		else if (dd < 0) putchar('-');
		else {
			if (cc > 0) putchar('+');
			else if (cc < 0) putchar('-');
			else putchar('=');
		}
		
		if (d[i - 1] % 2) pre = d[i - 1] % 2;
		d[i] = cnt[i] + d[i - 1] / 2;
	}
	putchar('\n');
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3764kb

input:

10
2 -1 4 -7 4 -8 3 -6 4 -7

output:

+=+-+---+-

result:

wrong answer 1st lines differ - expected: '+0+-+---+-', found: '+=+-+---+-'