QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#379519#8566. Can We Still Qualify For Semifinals?ucup-team3215#WA 1ms3804kbC++202.1kb2024-04-06 17:44:582024-04-06 17:44:59

Judging History

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

  • [2024-04-06 17:44:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3804kb
  • [2024-04-06 17:44:58]
  • 提交

answer

    #include <bits/stdc++.h>

    using namespace std;

    #define all(x) (x).begin(), (x).end()

    using pii = array<int, 2>;
    using vi = vector<int>;

    array<pii, 45> mt;

    void solve() {
        int n;
        string s;
        cin >> n >> s;
        vi w(10);
        for (int i = 0; i < n; ++i) {
            int b = s[i] - '0';
            ++w[mt[i][b ^ 1]];
        }
        for (int i = n; i < 45; ++i) {
            auto [x, y] = mt[i];
            if (x == 0) {
                ++w[x];
            }
        }
        vi wold(w);

        for (int i = n; i < 45; ++i) {
            auto [x, y] = mt[i];
            if (x == 0) {
                continue;
            }
            if (wold[x] > w[0]) {
                if (wold[y] > w[0]) {
                    if (w[x] > w[y]) {
                        swap(x, y);
                    }
                    ++w[x];
                } else {
                    ++w[x];
                }
            } else {
                if (wold[y] > w[0]) {
                    ++w[y];
                } else {
                    if (w[x] > w[y]) {
                        swap(x, y);
                    }
                    ++w[x];
                }
            }
        }

        vi srt(w);
        sort(all(srt), greater<>());
        cout << (w[0] >= srt[4] ? "YES" : "NO") << '\n';
    }

    int main() {
        vi p(10);
        iota(all(p), 0);
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 5; ++j) {
                mt[i * 5 + j] = {p[j], p[9 - j]};
            }
            vi pn(p);
            pn[1] = p.back();
            for (int j = 2; j < 10; ++j) {
                pn[j] = p[j - 1];
            }
            p = pn;
        }
        // for (int i = 0; i < 45; ++i) {
        //     if (i % 5 == 0) {
        //         cout << endl;
        //     }
        //     cout << mt[i][0] + 1 << ' ' << mt[i][1] + 1 << endl;
        // }
        int t;
        cin >> t;
        while (t--) {
            solve();
        }
    }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3
111
25
1000010101111111111010100
35
01111011110111101111011110111101111

output:

YES
YES
NO

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

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

input:

10
16
0110000001010100
17
01111000110110101
15
001100010101111
16
0010101010011100
19
0000000100010110100
16
0011101010011100
18
011110010001100000
18
000110101001100011
20
01100010000100100100
15
001000111001101

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 10 token(s): yes count is 10, no count is 0

Test #3:

score: 0
Accepted
time: 1ms
memory: 3564kb

input:

10
37
0110000001010100011101001011100110001
39
000100111101101001100101101000000000100
35
00111000100111100101011010111100100
33
010000010001110010110001101110001
30
000100010100000010010110101010
31
0000101000011010101001010000000
44
00001000000111101011010110000101100011000100
42
01111011110001001...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO

result:

ok 10 token(s): yes count is 0, no count is 10

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3568kb

input:

10
23
01100000010101000111010
38
01111001100011000101011110101001101001
27
010000000001001001110001001
26
01101001110011101101000110
8
00001000
22
0110100110001110110001
9
000100010
24
000000100101101010100100
6
011000
29
01101010100101000000000000100

output:

YES
NO
NO
NO
YES
NO
YES
NO
YES
NO

result:

wrong answer expected YES, found NO [6th token]