QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#782795#2808. GardeningMrSpoony0 11ms4076kbC++232.6kb2024-11-25 21:28:572024-11-25 21:28:57

Judging History

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

  • [2024-11-25 21:28:57]
  • 评测
  • 测评结果:0
  • 用时:11ms
  • 内存:4076kb
  • [2024-11-25 21:28:57]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
template <typename T> using V = vector<T>;

#define dl "\n"

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll T;
    cin >> T;

    while (T--) {
        ll n, m, k;
        cin >> n >> m >> k;

        if (n != m) {
            cout << "ignored" << dl;
            continue;
        }

        V<V<ll>> dp(n + 1, V<ll>(k + 1));
        dp[0][0] = -1;

        for (ll i = 1; i < n + 1; i++) {
            for (ll j = 1; j < k + 1; j++) {
                if (i - 2 >= 0 && dp[i - 2][j - 1] != 0)
                    dp[i][j] = 1;
                if (i - 2 >= 0 && j - i + 1 >= 0 && dp[i][j] == 0 && dp[i - 2][j - i + 1] != 0)
                    dp[i][j] = 2;
            }
        }

        if (dp[n][k] == 0) {
            cout << "NO" << dl;
            continue;
        }

        cout << "YES" << dl;
        V<V<ll>> grid(n, V<ll>(n, 0));
        auto draw = [&](ll x, ll y, ll x_len, ll y_len, ll color) {
            for (ll i = x; i < x + x_len; i++) {
                grid[x][i] = color;
                grid[x + x_len - 1][i] = color;
            }
            for (ll i = y; i < y + y_len; i++) {
                grid[i][y] = color;
                grid[i][y + y_len - 1] = color;
            }
        };

        ll sidelen = n, colors = k;
        ll x = 0, y = 0;
        while (sidelen > 0 && colors > 0) {
            if (dp[sidelen][colors] == 1) {
                draw(x, y, sidelen, sidelen, colors);
                x++;
                y++;
                colors--;
            } else if (dp[sidelen][colors] == 2) {
                for (ll myx = x; myx < x + sidelen; myx += 2) {
                    for (ll i = myx; i < myx + 2; i++) {
                        for (ll j = y; j < y + 2; j++) {
                            grid[i][j] = colors;
                        }
                    }
                    colors--;
                }
                for (ll myy = y + 2; myy < y + sidelen; myy += 2) {
                    for (ll i = myy; i < myy + 2; i++) {
                        for (ll j = x; j < x + 2; j++) {
                            grid[j][i] = colors;
                        }
                    }
                    colors--;
                }
                x += 2;
                y += 2;
            } else {
                break;
            }

            sidelen -= 2;
        }

        for (auto x : grid) {
            for (auto y : x)
                cout << y << " ";
            cout << dl;
        }
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 11ms
memory: 3576kb

input:

28119
2 4 2
2 2 1
4 2 2
2 2 1
2 2 1
2 2 3
2 4 2
4 4 2
2 2 2
2 2 2
4 4 3
2 2 1
4 2 2
4 4 4
4 2 2
2 4 2
2 2 2
2 2 2
2 2 1
2 2 1
2 2 1
2 2 1
2 2 2
2 2 1
2 4 2
2 2 1
2 2 1
2 2 1
4 2 2
2 2 2
2 2 1
2 2 1
2 2 1
2 2 1
2 2 1
4 2 7
2 2 1
2 4 2
2 2 1
4 2 2
2 4 2
2 2 1
2 4 4
2 2 1
2 2 1
2 2 1
4 2 2
2 2 2
2 2 1
...

output:

ignored
YES
1 1 
1 1 
ignored
YES
1 1 
1 1 
YES
1 1 
1 1 
NO
ignored
YES
2 2 2 2 
2 1 1 2 
2 1 1 2 
2 2 2 2 
NO
NO
NO
YES
1 1 
1 1 
ignored
YES
4 4 2 2 
4 4 2 2 
3 3 1 1 
3 3 1 1 
ignored
ignored
NO
NO
YES
1 1 
1 1 
YES
1 1 
1 1 
YES
1 1 
1 1 
YES
1 1 
1 1 
NO
YES
1 1 
1 1 
ignored
YES
1 1 
1 1 
YES...

result:

wrong answer Incorrect output (test case 1)

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 5ms
memory: 3928kb

input:

311
2 2 1
12 12 14
6 6 6
40 40 297
28 28 82
30 30 74
4 4 10
38 38 210
6 6 4
42 42 365
8 8 11
16 16 30
6 6 7
22 22 38
10 10 5
2 2 2
12 12 19
16 16 52
28 28 124
26 26 92
2 2 2
28 28 25
20 20 19
18 18 43
4 4 3
30 30 78
26 26 130
18 18 58
26 26 59
6 6 4
10 10 6
14 14 34
18 18 184
12 12 108
18 18 35
30 3...

output:

YES
1 1 
1 1 
YES
14 14 14 14 14 14 14 14 14 14 14 14 
14 13 13 13 13 13 13 13 13 13 13 14 
14 13 12 12 8 8 7 7 6 6 13 14 
14 13 12 12 8 8 7 7 6 6 13 14 
14 13 11 11 5 5 5 5 5 5 13 14 
14 13 11 11 5 4 4 2 2 5 13 14 
14 13 10 10 5 4 4 2 2 5 13 14 
14 13 10 10 5 3 3 1 1 5 13 14 
14 13 9 9 5 3 3 1 1 5 ...

result:

wrong answer Incorrect output (test case 3)

Subtask #5:

score: 0
Wrong Answer

Test #19:

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

input:

310
44 2 22
36 8 195
2 2 4
2 50 61
12 42 275
4 4 5
26 30 416
24 20 252
20 32 498
30 30 130
32 48 1153
46 16 574
4 40 89
6 28 64
10 16 9
18 42 152
4 14 1
6 50 280
10 10 87
44 24 395
2 2 4
40 46 273
34 34 607
22 22 300
40 40 1166
10 48 211
42 22 334
6 10 20
38 38 189
6 10 36
14 14 33
44 48 1518
32 18 ...

output:

ignored
ignored
NO
ignored
ignored
NO
ignored
ignored
ignored
NO
ignored
ignored
ignored
ignored
ignored
ignored
ignored
ignored
NO
ignored
NO
ignored
NO
NO
NO
ignored
ignored
ignored
YES
189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 189 ...

result:

wrong answer Incorrect output (test case 1)

Subtask #6:

score: 0
Skipped

Dependency #1:

0%