QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579977#9378. Strange BinarypaqiAC ✓12ms3772kbC++171.4kb2024-09-21 19:31:322024-09-21 19:31:33

Judging History

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

  • [2024-09-21 19:31:33]
  • 评测
  • 测评结果:AC
  • 用时:12ms
  • 内存:3772kb
  • [2024-09-21 19:31:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long
/*int qp(int a,int b){
	int res=1;
}*/
string to2bit(int n){
	string s="";
	if(n==0)s+="0";
	while(n){
		s+='0'+n%2;
		n/=2;
	}
	return s;
}

int ans[35];
void paqi(){
	// int n=tt;
	int n ;cin>>n;
	//n=rand()%998244353;
	for(int i=0;i<32;i++){
		ans[i]=-1;
	}
	ans[31]=1;
	//int n;cin>>n;
	// cout<<n;
	//cout<<n;
	n--;
	if(n==-1){
		cout<<"NO";
		return ;
	}
	if(n==0){
		cout<<"YES\n";
		cout<<"-1 -1 -1 -1 -1 -1 -1 -1\n";
		cout<<"-1 -1 -1 -1 -1 -1 -1 -1\n";
		cout<<"-1 -1 -1 -1 -1 -1 -1 -1\n";
		cout<<"-1 -1 -1 -1 -1 -1 -1 1";
		return ;
	}
	string s=to2bit(n);
	// cout<<s;
	// int sss=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1')ans[i]+=1;
		// sss+=ans[i]*(1ll<<i);
	}
	// if(sss!=n+1)cout<<"aaa";
	
	for(int i=0;i<32;i++){
		if(ans[i]==1&&ans[i+1]==0&&i!=31){
			ans[i]=-1;ans[i+1]=1;			
		}
		if(ans[i]==-1&&ans[i+1]==0&&i!=31){
			ans[i]=1;ans[i+1]=-1;
		}
	}
	// sss=0;
	for(int i=0;i<32;i++){
		// sss+=ans[i]*(1ll<<i);
		if(i!=31&&ans[i]==0&&ans[i+1]==0){
			cout<<"NO";return ;
		}
	}
	// if(sss!=n+1)cout<<"ttt";
	cout<<"YES\n";
	for(int i=0;i<32;i++){
		if(i!=7&&i!=15&&i!=23&&i!=31)cout<<ans[i]<<" ";
		else cout<<ans[i];
		if(i!=31&&(i+1)%8==0)cout<<'\n';
	}
	
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;cin>>t;
	while(t--){
		paqi();	
		if(t)cout<<"\n";
	}
	return 0;
}

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

詳細信息

Test #1:

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

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

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: 12ms
memory: 3648kb

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

result:

ok Accepted! (10000 test cases)

Extra Test:

score: 0
Extra Test Passed