QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#613051#4797. Xormitesucup-team4153#WA 0ms3748kbC++201007b2024-10-05 13:29:282024-10-05 13:29:30

Judging History

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

  • [2024-10-05 13:29:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3748kb
  • [2024-10-05 13:29:28]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
const int N = 5e4 + 7;
int T, n;
int a[N];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> a[i];
    for (int i = 30; i >= 0; i--) {
        vector<int> b(n + 1, 0);
        int sum = 0;
        for (int j = 1; j <= n; j++) {
            b[j] = a[j] >> i & 1;
            sum += b[j];
        }
        if (sum % 2 == 0)continue;
        sum--;
        stack<int> stk;
        for (int i = 1; i <= n; i++) {
            if (stk.size() && stk.top() == b[i])stk.pop();
            else stk.push(b[i]);
        }
        if (stk.size() == 1) {
            if (sum / 2 % 2 == 0)cout << "First\n";
            else cout << "Second\n";
        } else if (stk.size() % 2 == 0)cout << "First\n";
        else cout << "Second\n";
        return;
    }
    cout << "Draw\n";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while (T--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2
3 3
2
3 5
3
4 4 4

output:

Draw
First
Second

result:

ok 3 lines

Test #2:

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

input:

12
10
1 3 1 3 3 3 2 1 3 3
10
1 3 3 3 1 3 2 1 1 3
9
1 2 3 3 3 1 2 2 3
9
1 3 2 1 3 3 2 2 2
10
3 2 2 2 3 3 1 2 1 2
10
2 1 2 3 3 3 3 2 3 2
10
2 1 1 3 3 1 1 1 2 1
10
2 1 1 1 1 1 1 2 2 3
10
2 1 2 1 1 2 2 3 3 3
9
2 2 1 1 3 3 1 2 3
9
1 3 3 2 2 2 2 3 2
10
1 1 1 1 1 2 2 2 1 2

output:

First
First
Second
Second
First
First
Draw
First
First
Draw
Draw
Draw

result:

ok 12 lines

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3536kb

input:

12
9
3 4 1 5 2 1 5 3 1
10
6 2 4 5 4 2 5 7 5 6
9
5 3 2 1 2 4 4 1 4
9
5 7 6 2 7 2 5 7 4
10
7 5 1 6 7 1 5 1 4 5
10
4 2 6 2 7 2 2 2 3 5
10
7 3 4 7 4 4 2 3 7 5
9
3 3 7 1 6 3 7 2 3
10
5 3 7 7 2 6 4 7 3 1
10
1 7 4 2 4 2 6 6 4 4
10
4 1 3 4 4 4 5 4 1 7
9
4 3 4 7 1 6 2 2 5

output:

Second
First
Second
Second
First
First
First
Second
First
First
First
First

result:

wrong answer 12th lines differ - expected: 'Second', found: 'First'