답안 #856642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856642 2023-10-04T07:12:50 Z iulia_morariu Gardening (RMI21_gardening) C++17
0 / 100
107 ms 956 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, 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;
            }

            x = x1, y = y1;

            if(x == n) break;
            if(y == m){
                x += 2;
                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;
}
# 결과 실행 시간 메모리 Grader output
1 Failed 107 ms 956 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 107 ms 956 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 107 ms 956 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 13 ms 692 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 5 ms 348 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 107 ms 956 KB Output contains flowers without two equal neighbours
2 Halted 0 ms 0 KB -