QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181357#6643. Graphs and ColorsUrgantTeamWA 0ms3668kbC++233.3kb2023-09-16 18:02:142023-09-16 18:02:14

Judging History

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

  • [2023-09-16 18:02:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3668kb
  • [2023-09-16 18:02:14]
  • 提交

answer

#include <iostream>
#include <vector>

#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long double ld;
typedef long long ll;

int matr[105][105];
vector <pair <int, int> > tree[105];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);

    int test;
    cin >> test;

    for (int rep = 1; rep <= test; rep++)
    {
        int n, need;
        cin >> n >> need;
        if (n < 2 * need)
        {
            cout << "NO\n";
            continue;
        }
        cout << "YES\n";
        for (int i = 1; i <= n / 2; i++) tree[i].clear();

        if (n % 2 == 0)
        {
            int k = n / 2;
            for (int i = 1; i <= k; i++)
            {
                tree[i].pb(mp(i, i + k));
                for (int j = 1; j < k; j++)
                {
                    int a = i + j;
                    int b = (i + k + j - 1) % n + 1;
                    tree[i].pb(mp(i, a));
                    tree[i].pb(mp(i + k, b));
                }
            }

            for (int i = need + 1; i <= k; i++)
                for (const auto &[u, v] : tree[i])
                    tree[need].pb(mp(u, v));

            for (int u = 1; u <= n; u++)
                for (int v = u + 1; v <= n; v++)
                    matr[u][v] = 0;

            for (int i = 1; i <= need; i++)
            {
                for (const auto &[u, v] : tree[i])
                {
                    if (u < v) matr[u][v] = i;
                    else matr[v][u] = i;
                }
            }

            for (int u = 2; u <= n; u++)
            {
                for (int v = 1; v < u; v++)
                    cout << matr[v][u] << ' ';
                cout << '\n';
            }
        }
        else
        {
            int k = n / 2;
            for (int i = 1; i <= k; i++)
            {
                tree[i].pb(mp(i, i + k));
                for (int j = 1; j < k; j++)
                {
                    int a = i + j;
                    int b = (i + k + j - 1) % (n - 1) + 1;
                    tree[i].pb(mp(i, a));
                    tree[i].pb(mp(i + k, b));
                }
            }

            for (int i = need + 1; i <= k; i++)
                for (const auto &[u, v] : tree[i])
                    tree[need].pb(mp(u, v));

            for (int u = 1; u <= n; u++)
                for (int v = u + 1; v <= n; v++)
                    matr[u][v] = 0;

            for (int i = 1; i <= 2 * k; ++i)
                if (i <= k)
                    tree[i].pb(mp(i, 2 * k + 1));
                else
                    tree[1].pb(mp(i, 2 * k + 1));

            for (int i = 1; i <= need; i++)
            {
                for (const auto &[u, v] : tree[i])
                {
                    if (u < v) matr[u][v] = i;
                    else matr[v][u] = i;
                }
            }

            for (int u = 2; u <= n; u++)
            {
                for (int v = 1; v < u; v++)
                    cout << matr[v][u] << ' ';
                cout << '\n';
            }

        }
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3668kb

input:

768
8 24
7 20
17 61
17 76
16 100
16 16
15 59
9 17
14 31
14 61
10 32
17 55
5 7
10 29
14 82
13 47
17 32
5 10
16 76
14 59
8 28
13 19
12 41
13 41
11 32
11 53
3 2
16 52
16 87
7 12
9 15
15 65
15 53
17 47
6 15
12 1
14 35
16 60
12 31
14 70
15 88
12 2
8 23
12 38
16 111
16 117
5 4
14 90
12 55
15 41
15 48
15 4...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
1 
1 1 
1 1 1 
1 1 1 1 
1 1 1 1 1 
1 1 1 1 1 1 
1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 1 1 1 
NO
NO
NO
NO
NO
YES
1 
1 2 
1 2 2 
1 2 2 2 
1 2 2...

result:

wrong answer Integer parameter [name=col] equals to 0, violates the range [1, 4] (test case 52)