QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637813#7747. MemoryShwStoneWA 1ms4632kbC++141020b2024-10-13 14:09:122024-10-13 14:09:15

Judging History

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

  • [2024-10-13 14:09:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4632kb
  • [2024-10-13 14:09:12]
  • 提交

answer

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

const int MAXN(2e5 + 5);

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

int main() {
	memset(tt, 0x3f, sizeof tt);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x, c = 1;
		scanf("%d", &x);
		if (x < 0) x = -x, c = -1;

		for (int j = 31; j >= 0; j--) {
			cnt[i + j] += c * ((x >> j) & 1);
		}
		
		int s = i - 1;
		int tmp = 0;
		for (int j = s; j >= 1; j--) {
			tmp *= 2;
			if (abs(tmp) > n) break;
			if (j < s && tt[j] != 0x3f3f3f3f) {
				tmp += tt[j];
				break;
			} else tmp += cnt[j];
			if (abs(tmp) > n) break;
		}
		if (abs(tmp) <= n) tt[s] = tmp;
		else tt[s] = 0x3f3f3f3f;

		tmp = 0;
		for (int j = i + 31; j >= 1; j--) {
			tmp *= 2;
			if (abs(tmp) > n) break;
			if (j <= s && tt[j] != 0x3f3f3f3f) {
				tmp += tt[j];
				break;
			} else tmp += cnt[j];
			if (abs(tmp) > n) break;
		}

		if (tmp > 0) putchar('+');
		else if (tmp < 0) putchar('-');
		else putchar('0');
	}
	putchar('\n');
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

+0+-+---+-

result:

ok single line: '+0+-+---+-'

Test #2:

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

input:

10
-1 36 18 18 18 18 18 18 18 -18

output:

-+++++++++

result:

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