QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#484840#8651. Table TennisQwerty1232#0 550ms3652kbC++231.4kb2024-07-20 02:59:102024-07-20 02:59:11

Judging History

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

  • [2024-07-20 02:59:11]
  • 评测
  • 测评结果:0
  • 用时:550ms
  • 内存:3652kb
  • [2024-07-20 02:59:10]
  • 提交

answer

#include <bits/stdc++.h>

int count(int n, const std::vector<std::vector<bool>> &data) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (data[i][j] == data[j][k] && data[j][k] == data[k][i]) {
                    cnt++;
                }
            }
        }
    }
    return cnt;
}

std::mt19937 rnd;

void solve() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::vector<bool>> ans(n, std::vector<bool>(n));
    // clock_t beg = clock();
    for (int t = 0; t < 1e5 * n * n * n; t++) {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int b = rnd() % int(1e9 + 7) % 2;
                ans[i][j] = b;
                ans[j][i] = !b;
            }
        }
        int cnt = count(n, ans);
        if (cnt == m) {
            std::cout << "Yes\n";
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    std::cout << ans[i][j] << " \n"[j == i - 1];
                }
            }

            return;
        }
    }
    std::cout << "No\n";
}

int32_t main() {
    std::ios_base::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

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

97
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
24 0
25 0
26 0
27 0
28 0
29 0
30 0
31 0
32 0
33 0
34 0
35 0
36 0
37 0
38 0
39 0
40 0
41 0
42 0
43 0
44 0
45 0
46 0
47 0
48 0
49 0
50 0
51 0
52 0
53 0
54 0
55 0
56 0
57 0
58 0
59 0
60 0
61 0
62 0
63 0...

output:


result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #58:

score: 4
Accepted
time: 550ms
memory: 3652kb

input:

1
4 4

output:

No

result:

ok good job! (1 test case)

Test #59:

score: -4
Time Limit Exceeded

input:

1
5 10

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%