Submission #642613

# Submission time Handle Problem Language Result Execution time Memory
642613 2022-09-20T09:12:44 Z Neacsu_Mihai Gardening (RMI21_gardening) C++14
5 / 100
16 ms 980 KB
#include <bits/stdc++.h>

using namespace std;

//ifstream fin ("test.in");
//ofstream fout ("test.out");

int v[1001][1001];
int cl;
void divide(int x1, int y1, int x2, int y2, int K){
    if(K == 0){
        cl = -1;
        return;
    }

    //printf("divide(%d, %d, %d, %d, %d)\n", x1, y1, x2, y2, K);

    int N = x2 - x1 + 1;
    int M = y2 - y1 + 1;

    if(N * M == 4 * K){
        ///umplu cu patrate
        for(int i = x1; i <= x2; i += 2){
            for(int j = y1; j <= y2; j += 2){
                v[i][j] = cl;
                v[i + 1][j] = cl;
                v[i][j + 1] = cl;
                v[i + 1][j + 1] = cl;
                cl++;
            }
        }
        return;
    }
    else if(N == 2 || M == 2){
        cl = -1;
        return;
    }
    else {
        for(int i = x1; i <= x2; i++){
            v[i][y1] = cl;
            v[i][y2] = cl;
        }
        for(int j = y1; j <= y2; j++){
            v[x1][j] = cl;
            v[x2][j] = cl;
        }

        cl++;

        divide(x1 + 1, y1 + 1, x2 - 1, y2 - 1, K - 1);
    }

}

void Solve()
{
    int N, M, K;
    cin >> N >> M >> K;

    if(N % 2 == 1 || M % 2 == 1){
        cout << "NO\n";
        return;
    }

    cl = 1;
    divide(1, 1, N, M, K);

    if(cl == -1){
        cout << "NO\n";
        return;
    }

    cout << "YES\n";
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            cout << v[i][j] << ' ';
        }
        cout << "\n";
    }
}

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

    int nrTeste;
    cin >> nrTeste;

    for(int q = 1; q <= nrTeste; q++){
        Solve();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 980 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 16 ms 980 KB Correct! Azusa and Laika like the garden :)
2 Failed 6 ms 468 KB Incorrect output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 980 KB Correct! Azusa and Laika like the garden :)
2 Failed 6 ms 468 KB Incorrect output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 468 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 468 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 980 KB Correct! Azusa and Laika like the garden :)
2 Failed 6 ms 468 KB Incorrect output
3 Halted 0 ms 0 KB -