QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580371#9378. Strange BinaryyywxdgyWA 1ms3488kbC++141.0kb2024-09-21 21:31:392024-09-21 21:31:40

Judging History

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

  • [2024-09-21 21:31:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3488kb
  • [2024-09-21 21:31:39]
  • 提交

answer

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int T, n;
int a[40], cnt = 0;
void Apply(int x, int l, int r) {
	a[l] = x; for (int i = l + 1; i <= r; ++i) a[i] = -x;
}
void Work(int nn) {
	n = nn;
	int y = n;
	cnt = 0, memset(a, 0, sizeof(a));
	while (y) a[++cnt] = y % 2, y >>= 1;
	cnt = 32;
	reverse(a + 1, a + cnt + 1);
	int conti = 0, l = 1, r;
	for (int i = 1; i <= cnt; ++i) {
		if (a[i] == 0) ++conti, (conti == 1 ? l = r = i : r = i);
		if (a[i] != 0 && conti > 1) Apply(a[i], l, r), a[i] = -a[i], conti = 0;
		if (a[i] != 0) l = r = i + 1;
	}
	if (conti > 1) return puts("NO"), void(); 
	puts("YES");
	reverse(a + 1, a + cnt + 1);
	int sum = 0;
	for (int i = 1; i <= cnt; ++i) 
		// sum += (a[i] << (i - 1)), 
		printf("%d%c", a[i], i%8!=0?' ':'\n');
	// cout << sum << endl;
	if (sum != n) { puts("114514"); exit(0);}
}
int main() {
	// cin >> T; while (T --) Work();
	// for (int i = 1; i <= 1000; ++i) Work(i);
	Work(0);
	return 0;
}
/*

11
0
1
2
3
4
5
6
7
8
9
10
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3488kb

input:

3
0
3
5

output:

NO

result:

wrong output format Unexpected end of file - token expected (test case 3)