QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#580631#9378. Strange BinarykalikariAC ✓24ms3828kbC++171.1kb2024-09-21 22:48:462024-09-21 22:48:47

Judging History

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

  • [2024-09-21 22:48:47]
  • 评测
  • 测评结果:AC
  • 用时:24ms
  • 内存:3828kb
  • [2024-09-21 22:48:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
/*
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
*/
typedef long long LL;
#define int long long
#define ld long double
//#define INT __int128
const LL INF = 0x3f3f3f3f3f3f3f3f;
typedef unsigned long long ULL;
typedef pair<long long, long long> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const ld eps = 1e-12;
const int N = 1e5 + 10, M = N + 10, K = N;
int n;

void solve(){
	cin>>n;
	n--;
	std::vector<int> v(32,-1);
	bool fg=0;
	for(int i=0;i<32;i++){
		if(n>>i&1){
			if(i>0){
				if(v[i-1]==0){
					fg=1;
					break;
				}
				v[i-1]=1;
			}
			else{
				v[i]=0;
			}
		}
	}
	if(fg){
		cout<<"NO"<<endl;
		return;
	}
	v[31]=1;
	cout<<"YES"<<endl;
	for(int i=0;i<32;i++){

		if(i%8==0&&i!=0)cout<<endl;
		cout<<v[i]<<" ";
	}
	cout<<endl;
}

signed main(){
	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
	int T=1,cas=1;
	cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

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: 3484kb

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: 0
Accepted
time: 24ms
memory: 3536kb

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
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 -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:

ok Accepted! (10000 test cases)

Extra Test:

score: 0
Extra Test Passed