Submission #856654

# Submission time Handle Problem Language Result Execution time Memory
856654 2023-10-04T07:30:52 Z iulia_morariu Gardening (RMI21_gardening) C++17
0 / 100
110 ms 860 KB
#include <bits/stdc++.h>
#pragma GCC target("popcnt")

using namespace std;

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

    //1.
    int n, m, k, t;

    //2.
    cin >> t;

    //3.
    for(int ii = 0; ii < t; ii++){
        cin >> n >> m >> k;

        if(k > (m / 2) * (n / 2)){
            cout << "NO" << endl;
            continue;
        }

        cout << "YES" << endl;
        int v[n][m];

        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++) v[i][j] = -1;
        }

        int x = 0, y = 0;
        for(int i = 1; i <= k - 1; i++){

            //cout << "i = " << i << " x = " << x << " y = " << y << endl;

            int x1 = x + 2, y1 = y + 2;

            v[x][y] = i;
            v[x][y + 1] = i;
            if(y + 1 == m - 2){
                v[x][y + 2] = i;
                y1++;
            }

            v[x + 1][y] = i;
            v[x + 1][y + 1] = i;
            if(y + 1 == m - 2) v[x + 1][y + 2] = i;

            if(x + 2 == n - 1){
                x1++;
                v[x + 2][y] = i;
                v[x + 2][y + 1] = i;
                if(y + 1 == m - 2) v[x + 2][y + 2] = i;
            }

            y = y1;
            if(x == n) break;
            if(y == m){
                x = x1;
                y = 0;
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(v[i][j] == -1) v[i][j] = k;
            }
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++) cout << v[i][j] << " ";
            cout << endl;
        }


    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Failed 110 ms 820 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 110 ms 820 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 110 ms 820 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 14 ms 860 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 5 ms 348 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 110 ms 820 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -