QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582601#9378. Strange BinaryQingFeng666WA 7ms3668kbC++14727b2024-09-22 16:57:012024-09-22 16:57:01

Judging History

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

  • [2024-09-22 16:57:01]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3668kb
  • [2024-09-22 16:57:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n, a[32];
void solve()
{
	memset(a, 0, sizeof(a));
	cin >> n;
	if (n == 0 || n % 4 == 0)
	{
		cout << "NO\n";
		return;
	}
	for (int i = 0; i < 32; i++) a[i] = ((n >> i) & 1);
	bool f = false;
	for (int i = 31; i >= 0; i--)
	{
		if (!f && a[i] == 0) a[i] = 1, f = true;
		else if (f && a[i] == 0) a[i] = -1;
		else if (f && a[i] == 1) a[i] = -1, f = false;
	}
	cout << "YES\n";
	for (int i = 0; i < 32; i++)
	{
		cout << a[i] << ' ';
		if ((i + 1) % 8 == 0) cout << '\n';
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int T; cin >> T;
	while (T--) solve();
	return 0;
}

詳細信息

Test #1:

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

input:

3
0
3
5

output:

NO
YES
1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 1 
YES
-1 1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 1 

result:

ok Accepted! (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

2
0
1073741823

output:

NO
YES
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 -1 -1 1 

result:

ok Accepted! (2 test cases)

Test #3:

score: -100
Wrong Answer
time: 7ms
memory: 3592kb

input:

10000
324097321
555675086
304655177
991244276
9980291
383616352
1071036550
795625380
682098056
68370721
969101726
685975156
973896269
354857775
196188000
606494155
754416123
467588829
495704303
558090120
618002000
491488050
741575237
9937018
10028830
140094825
652839595
357724903
516690123
817724271...

output:

YES
-1 -1 1 -1 1 -1 -1 1 
-1 1 -1 1 -1 1 -1 1 
-1 -1 -1 1 -1 1 -1 1 
1 -1 -1 1 -1 -1 -1 1 
YES
1 1 1 -1 -1 1 1 1 
-1 1 1 -1 1 1 1 -1 
1 1 1 1 -1 -1 -1 1 
-1 -1 -1 -1 1 -1 -1 1 
YES
-1 -1 1 -1 -1 1 -1 1 
1 -1 1 -1 1 -1 1 -1 
-1 -1 1 -1 1 -1 -1 -1 
1 -1 -1 1 -1 -1 -1 1 
NO
YES
1 -1 -1 -1 -1 -1 1 1 
-1...

result:

wrong answer Offend Limitation 3. (test case 10000)