QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#479557#8566. Can We Still Qualify For Semifinals?ucup-team3519#WA 12ms3764kbC++232.6kb2024-07-15 18:46:282024-07-15 18:46:28

Judging History

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

  • [2024-07-15 18:46:28]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:3764kb
  • [2024-07-15 18:46:28]
  • 提交

answer

#include <bits/stdc++.h>

std::mt19937 rbg(std::chrono::steady_clock::now().time_since_epoch().count());
auto B2 = std::bernoulli_distribution{0.5};
constexpr int N = 10;

void solve() {
    int k;
    std::cin >> k;

    std::string s;
    std::cin >> s;

    std::vector<std::pair<int, int>> matches;
    {
        std::vector<int> a(N);
        std::iota(a.begin(), a.end(), 0);

        auto roll = [](auto begin, auto end) {
            auto x = *(end - 1);
            for (auto it = end - 1; it != begin; --it) {
                *it = *(it - 1);
            }
            *begin = x;
        };
        for (int i = 1; i <= 9; ++i) {
            for (int j = 0; j < 5; ++j) {
                matches.emplace_back(a[j], a[N - 1 - j]);
            }
            roll(a.begin() + 1, a.end());
        }
    }

    std::vector<int> p(N);
    for (int i = 0; i < k; ++i) {
        if (s[i] == '1') {
            p[matches[i].first] += 1;
        } else {
            p[matches[i].second] += 1;
        }
    }

    for (int x = 0; x < N; ++x) {
        for (int y = 0; y < N; ++y) {
            for (int z = 0; z < N; ++z) {
                
                auto q = p;
                std::vector<std::pair<int, int>> vec;

                for (int _ = k; _ < matches.size(); ++_) {
                    auto [a, b] = matches[_];
                    if (a == 0 || b == 0) {
                        q[0] += 1;
                    } else if (a != x && a != y && a != z && b != x && b != y && b != z) {
                        vec.emplace_back(a, b);
                    }
                }

                for (int _ = 0; _ < 10; ++_) {
                    std::shuffle(vec.begin(), vec.end(), rbg);
                    for (auto [a, b] : vec) {
                        if (B2(rbg)) {
                            std::swap(a, b);
                        }
                        if (q[a] < q[b]) {
                            q[a] += 1;
                        } else {
                            q[b] += 1;
                        }
                    }
                    if (std::none_of(q.begin(), q.end(), [&](int v) {
                        return v > q[0];
                    })) {
                        std::cout << "YES\n";
                        return;
                    }
                }
            }
        }
    }

    std::cout << "NO\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3596kb

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: 3616kb

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: 12ms
memory: 3556kb

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: 10ms
memory: 3764kb

input:

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

output:

NO
NO
NO
NO
YES
YES
YES
YES
YES
NO

result:

wrong answer expected YES, found NO [1st token]