QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581489#9378. Strange BinaryshyiawAC ✓17ms3788kbC++171.0kb2024-09-22 13:04:002024-09-22 13:04:00

Judging History

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

  • [2024-09-22 13:04:00]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:3788kb
  • [2024-09-22 13:04:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define fi first
#define se second
#define pb push_back
#define endl "\n"
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
void solve(){
	ll n;cin>>n;
	vector<int> cur;
	rep(i,1,32){
		cur.pb(n&1);
		n>>=1;
	}	
	reverse(cur.begin(),cur.end());
	int tp=1;
	vector<int> ans;
	for(auto v:cur){
		//cout<<v<<endl;
		if(v==0){
			if(tp) ans.pb(1),tp^=1;
			else ans.pb(-1);
		}
		else{
			if(tp) ans.pb(1);
			else ans.pb(-1),tp^=1; 
		}
	}
	if(!tp&&cur[31]==cur[30]&&cur[31]==0){
		cout<<"NO"<<endl;
	}
	else{
		if(!tp){
			ans.pop_back();
			ans.pb(0);
		}
		cout<<"YES"<<endl;
		rep(i,1,4){
			int tot=0;
			while(tot<8){
				cout<<ans.back()<<" ";
				ans.pop_back();
				tot++;
			}
			cout<<endl;
		}
	}
}
int main(){
	IOS
	int t=1;cin>>t;
	while(t--) solve();
	return 0;
}

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

詳細信息

Test #1:

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

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

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: 17ms
memory: 3788kb

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