QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#580595#9378. Strange BinarykalikariWA 28ms3780kbC++171.2kb2024-09-21 22:37:222024-09-21 22:37:22

Judging History

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

  • [2024-09-21 22:37:22]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:3780kb
  • [2024-09-21 22:37:22]
  • 提交

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;
	int cn=0;
	for(int i=31;i>=0;i--){
		if(n>>i&1)cn++;
	}
	if(cn<=1){
		cout<<"NO"<<endl;
		return ;
	}
	n--;
	std::vector<int> v(32,-1);
	// for(int i=31;i>=0;i--){
	// 	if(n>>i&1){
	// 		if(i>0)
	// 			v[i-1]=1;
	// 		else
	// 			v[i]=0;
	// 	}
	// }
	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;
			}
		}
	}
	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;
}

详细

Test #1:

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

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

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: 28ms
memory: 3780kb

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 
YES
0 -1 -1 -1 -1 -1 -1 -1 
-1 ...

result:

wrong answer Offend Limitation 3. (test case 10000)