QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202128#6642. (1, 2) Nimarseny_y#WA 6ms3808kbC++231.6kb2023-10-05 19:46:352023-10-05 19:46:36

Judging History

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

  • [2023-10-05 19:46:36]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3808kb
  • [2023-10-05 19:46:35]
  • 提交

answer

//I wrote this code 4 u today
#include <bits/stdc++.h>

template<class t> using vc = std::vector<t>;

#define nd node*
#define pnd pair<nd, nd>

using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vc<pll> vpll;
typedef vc<vll> vvll;
typedef vc<vpll> vvpll;

template<const ll MOD>
struct mod_mul : std::multiplies<const ll> {
    ll operator()(const ll a, const ll b) {
        return (a * b) % MOD;
    }
};


template<typename T>
inline void sort(T &a) {
    sort(a.begin(), a.end());
}

template<typename T>
inline void unique(T &a) {
    a.resize(unique(a.begin(), a.end()) - a.begin());
}

template<typename T>
inline void reverse(T &a) {
    reverse(a.begin(), a.end());
}

const ll INF = 9023372036854775808ll;
const ll MOD = 1000000007ll;

int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vc<int> a(n);
        for (auto &i : a) cin >> i;
        if (n == 1) cout << "Sprague\n";
        else {
            int xr = 0;
            std::sort(a.begin(), a.end());
            std::reverse(a.begin(), a.end());
            for (auto &i : a) xr ^= i;
            int z = xr ^ 1;
            if (z > a.back()) {
                cout << "Grundy\n";
                continue;
            }
            a.back() -= z;
            bool fl = true;
            for (auto &x : a) fl &= x < 3;
            if (fl) {
                if (n == 1) cout << "Sprague\n";
            } else {
                cout << "Grundy\n";
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2
1 2
1
5
4
1 7 2 9

output:

Grundy
Sprague
Grundy

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 6ms
memory: 3656kb

input:

11337
9
4 1 2 3 2 4 3 2 3
10
1 7 1 5 1 2 2 2 1 3
9
1 3 7 3 3 1 1 3 2
12
1 1 2 4 1 2 2 4 2 2 1 4
15
1 3 4 3 1 2 1 4 1 1 1 1 1 1 1
8
3 3 2 2 3 9 1 2
10
2 2 2 2 1 5 1 2 7 2
10
2 2 2 3 2 2 3 5 2 2
7
2 2 6 2 2 3 5
10
1 1 1 3 1 1 1 5 1 1
8
2 2 2 2 5 2 10 1
5
3 10 1 3 1
8
3 4 2 2 1 1 11 1
6
6 4 8 2 4 2
10
...

output:

Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy
Grundy...

result:

wrong answer 22nd lines differ - expected: 'Sprague', found: 'Grundy'