답안 #645942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
645942 2022-09-28T10:20:13 Z MadokaMagicaFan Gardening (RMI21_gardening) C++14
5 / 100
78 ms 892 KB
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;

#define forn(i,n)   for(int i = 0; i < n; ++i)
#define pb          push_back
#define sz(v)       ((int)((v).size()))

void
doframe(int t, int x, int y, int w, int h, vector<vi> &a)
{
    for (int i = 0; i < w; ++i) {
        a[x+i][y] = t;
        a[x+i][y+h-1] = t;
    }

    for (int i = 0; i < h; ++i) {
        a[x][y+i] = t;
        a[x+w-1][y+i] = t;
    }
    return;
}

void
solve()
{
    int n, m, k;

    cin >> n >> m >> k;
    bool t = 0;
    vector<vi> ans;
    int v, c;
    int w, h;
    int o= 0;
    int oy, ox;
    int tval;

    if (n & 1)
        goto untrue;
    if (m & 1)
        goto untrue;

    n >>= 1;
    m >>= 1;


    if (n > k)
        goto untrue;
    if (m > k)
        goto untrue;


    for (int i = 0; i < n && i <= m; ++i) {
        if (k % (n-i) == i && (k/(n-i)) <= m-i && (k/(n-i)) * (n-i) >= m-i) {
            t = 1;
            v = 0;
            c = i;
            break;
        }
    }

    for (int i = 0; i < m && i <= n; ++i) {
        if (k % (m-i) == i && (k/(m-i)) <= n-i && (k/(m-i)) * (m-i) >= n-i) {
            v = 1;
            c = i;
            t = 1;
            break;
        }
    }

    if (!t)
        goto untrue;


    cout << "YES\n";

    if (!v)
        swap(n,m);
    ans.assign(n<<1,{});

    for (int i = 0; i < (n<<1); ++i) {
        ans[i].assign(m<<1,0);
    }

    for (int i = 0; i < c; ++i) {
        doframe(i+1, i, i, (n-i)<<1, (m-i)<<1, ans);
    }

    w = n - c;
    h = m - c;
    k -= c;
    o = c;
    oy = c;
    ox = c;

    for (int i = 0; i < k/h; ++i) {
        o = min(w+i-k/h, h-1);
        /* if (w > ((k/h) - i)) { */
            for (int j = 0; j < o; ++j) {
                doframe(i*h + c+1 +j, ox+j, oy+j, (o-j+1)<<1, (h-j)<<1, ans);
            }
        /* } */

        for (int j = o; j < h; ++j) {
            doframe(i*h+c+1+j, ox+o, oy-o+2*j, 2, 2, ans);
        }
        w -= (1 + o);
        ox += ((1 + o)<<1);
        /* w -= 1kkkkkkkk */
    }

    if (!v)
        swap(n,m);

    for (int i = 0; i < (n<<1); ++i) {
        for (int j = 0; j < (m<<1); ++j) {
            if (!v)
                cout << ans[j][i] << ' ';
            else
                cout << ans[i][j] << ' ';
        }
        cout << endl;
    }


    return;

    untrue:
    cout << "NO\n";
    return;
}

int32_t
main(int argc, char *argv[])
{
    if (argc>1)
        freopen(argv[1], "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t;

    cin >> t;

    while (t--)
        solve();
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:40:9: warning: unused variable 'tval' [-Wunused-variable]
   40 |     int tval;
      |         ^~~~
Main.cpp: In function 'int32_t main(int, char**)':
Main.cpp:141:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  141 |         freopen(argv[1], "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 892 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 892 KB Correct! Azusa and Laika like the garden :)
2 Failed 14 ms 552 KB Incorrect output
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 892 KB Correct! Azusa and Laika like the garden :)
2 Failed 14 ms 552 KB Incorrect output
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 6 ms 468 KB Incorrect output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 2 ms 340 KB Incorrect output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 892 KB Correct! Azusa and Laika like the garden :)
2 Failed 14 ms 552 KB Incorrect output
3 Halted 0 ms 0 KB -