QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#152882 | #6570. Who Watches the Watchmen? | BUET_POISSON | TL | 0ms | 0kb | C++14 | 1.3kb | 2023-08-28 22:08:59 | 2023-08-28 22:08:59 |
answer
#include <bits/stdc++.h>
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0)
#define setbit0(n, i) ((n) & (~(1LL << (i))))
#define setbit1(n, i) ((n) | (1LL << (i)))
#define togglebit(n, i) ((n) ^ (1LL << (i)))
#define lastone(n) ((n) & (-(n)))
char gap = 32;
#define int long long
#define ll long long
#define lll __int128_t
#define pb push_back
void solve() {
int n;
cin >> n;
int o = 0, e = 0;
int cnt[n] = {0};
for (int i=0; i<n; i++) {
int x;
cin >> x;
if (x & 1) o++;
else e++;
while(x%2==0) {
cnt[i]++;
x/=2;
}
}
if (n % 2 == 0) {
if (e) {
cout << 1 << endl;
}
else {
cout << 0 << endl;
}
} else {
if (e == n) {
for(int i=1;i<n;i++){
if( cnt[i]!=cnt[i-1] ){
cout<<1<<endl;
return;
}
}
cout<<0<<endl;
}
else if (e) {
cout << 1 << endl;
}
else {
cout << 0 << endl;
}
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t; cin >> t;
while(t--) {
solve();
}
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
7 0 0 0 1 0 0 1 0 0 -1 0 0 2 0 0 1 0 0 3 0 0 1 0 0 4 0 0 1 0 0 5 0 0 1 0 0 6 0 0 -1 0 0
output:
0 0 0