QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580840#9378. Strange BinaryJOFISHWA 0ms3656kbC++23864b2024-09-22 00:17:592024-09-22 00:18:11

Judging History

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

  • [2024-09-22 00:18:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3656kb
  • [2024-09-22 00:17:59]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using LL = long long;
int arr[32];
vector<int> chances;
bool flag = 1;
int T;
LL n, Z;
int main() {
	cin>>T;
	while(T--) {
		ios::sync_with_stdio(0);
		cin.tie(0), cout.tie(0);
		chances.clear();
		memset(arr, -1, sizeof arr);
		arr[31] = 1;
		cin>>n;
		if (!n) {
			cout<<"NO\n";
			continue;	
		}
		
		Z = n - 1;
		for (LL i =1, j = 0; i<=Z; i<<=1, j++) 
			if (Z&i) chances.push_back(j);
			
		for (int i=chances.size()-1 ; ~i && flag; i--) {
			if (chances[i] == 0 && arr[0] != -1) flag = 0;
			if (chances[i] == chances[i+1] + 1) arr[chances[i]-1] = 1;
			else if (arr[chances[i]] != -1) arr[chances[i]-1] = 1;
			else arr[chances[i]] = 0;
		}
		
		cout<<(flag ? "YES" : "NO")<<"\n";
		
		for (int i=0; i<32; i++)
			cout<<arr[i]<<" \n"[(i+1)%8 == 0];
		cout<<"\n";
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

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 0 -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: -100
Wrong Answer
time: 0ms
memory: 3588kb

input:

2
0
1073741823

output:

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


result:

wrong answer Offend Limitation 2. (test case 2)