QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152882#6570. Who Watches the Watchmen?BUET_POISSONTL 0ms0kbC++141.3kb2023-08-28 22:08:592023-08-28 22:08:59

Judging History

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

  • [2023-08-28 22:08:59]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [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

result: