QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207943#6569. Splitting PairsFreeuni1#WA 3ms3528kbC++141.4kb2023-10-08 23:43:282023-10-08 23:43:28

Judging History

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

  • [2023-10-08 23:43:28]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3528kb
  • [2023-10-08 23:43:28]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
    int n, m, k;
vector<array<int, 4> > v, v1;
vector<array<int, 2> > w[2222];
int d[2222], ok[3333];
vector<array<int, 2> > ans;

int gpar(int a) {
    if (d[a] == a) return a;
    return d[a] = gpar(d[a]);
}

bool dsu(int a, int b) {
    a = gpar(a);
    b = gpar(b);
    if (a == b) {
        return false;
    }
    d[a] = b;
    return true;
}

int dfs(int idx, int par, int tar, int ans) {
    //cout << idx << "< >" << tar << endl;

    if (idx == tar) {
        return ans;
    }
    for (auto it: w[idx]) {
        if (it[0] == par) {
            continue;
        }
        //cout << it[1] << "!!";
        if (ans == -1 && ok[it[1]] && it[1] >= n-1) {

            int pas = dfs(it[0], idx, tar, it[1]);
            if (pas != -1) {
                return pas;
            }
        } else if (ok[it[1]]) {
            int pas = dfs(it[0], idx, tar, ans);
            if (pas != -1) {
                return pas;
            }
        }
    }
    return -1;
}
main() {

    int t;
    cin >> t;
    while (t -- ) {
    int n, lw =0 , kn = 0;
    cin >> n;
    for (int i = 0; i < n; i ++) {
        int a;
        cin >> a;
        if (a == 2) {
            lw ++;
        }
    if (a%2 == 1) kn ++;
    }
    if ((lw == n && n%2 == 1) || kn == n) cout << 0;
    else cout << 1;
    cout << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
3
1 1 1
3
1 1 2
3
2 2 2
4
4 4 4 4

output:

0
1
0
1

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3476kb

input:

1000
10
16 16 16 16 16 16 16 16 16 16
10
16 16 16 16 16 16 16 16 17 16
10
16 16 16 16 16 16 16 18 16 16
10
16 16 16 19 16 16 16 16 16 16
10
16 16 16 16 20 16 16 16 16 16
10
17 16 16 16 17 16 16 16 16 16
10
16 16 16 16 16 16 16 16 18 17
10
16 16 19 16 16 16 16 17 16 16
10
17 16 16 16 16 16 16 20 16 1...

output:

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

result:

ok 1000 lines

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 3440kb

input:

1000
2
4 4
2
5 4
2
4 6
2
7 4
2
4 8
2
5 5
2
6 5
2
7 5
2
8 5
2
6 6
2
7 6
2
8 6
2
7 7
2
7 8
2
8 8
3
4 4 4
3
4 5 4
3
4 4 6
3
4 7 4
3
8 4 4
3
4 5 5
3
6 4 5
3
4 5 7
3
8 5 4
3
6 4 6
3
7 4 6
3
8 4 6
3
4 7 7
3
7 8 4
3
8 8 4
3
5 5 5
3
5 6 5
3
5 5 7
3
5 8 5
3
6 5 6
3
6 7 5
3
6 5 8
3
7 7 5
3
8 5 7
3
5 8 8
3
6 6...

output:

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

result:

wrong answer 16th lines differ - expected: '0', found: '1'