Submission #856666

# Submission time Handle Problem Language Result Execution time Memory
856666 2023-10-04T09:01:46 Z iulia_morariu Gardening (RMI21_gardening) C++17
0 / 100
101 ms 828 KB
#include <bits/stdc++.h>

using namespace std;

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

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

    //2.
    cin >> t;

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

        if(n % 2 == 1 || m % 2 == 1){
            cout << "NO" << endl;
            continue;
        }

        if(n == 2 && m == 2 && k == 1){
            cout << "YES" << endl;
            cout << "1 1" << endl;
            cout << "1 1" << endl;
            continue;
        }

        if(n == 2 && m == 4 && k == 2){
            cout << "YES" << endl;
            cout << "1 1 2 2" << endl;
            cout << "1 1 2 2" << endl;
            continue;
        }

        if(n == 4 && m == 2 && k == 2){
            cout << "YES" << endl;
            cout << "1 1" << endl;
            cout << "1 1" << endl;
            cout << "2 2" << endl;
            cout << "2 2" << endl;
            continue;
        }

        if(n == 4 && m == 4 && k == 2){
            cout << "YES" << endl;
            cout << "1 1 1 1" << endl;
            cout << "1 2 2 1" << endl;
            cout << "1 2 2 1" << endl;
            cout << "1 1 1 1" << endl;
            continue;
        }

        if(n == 4 && m == 4 && k == 4){
            cout << "YES" << endl;
            cout << "1 1 2 2" << endl;
            cout << "1 1 2 2" << endl;
            cout << "3 3 4 4" << endl;
            cout << "3 3 4 4" << endl;
            continue;
        }


        if(n == 2 && m / 2 == k){
            cout << "YES" << endl;
            int it = 0;
            for(int i = 0; i < m; i++){
                if(i % 2 == 0) it++;
                cout << it << " ";
            }
            cout << endl;
            it = 0;
            for(int i = 0; i < m; i++){
                if(i % 2 == 0) it++;
                cout << it << " ";
            }
            cout << endl;
            continue;
        }

        if(n != 4){
            cout << "NO" << endl;
            continue;
        }

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

        int m1 = m;
        int cate = INT_MAX;
        for(int it = 0; it <= k; it += 2){
            if( (m1 - 2) / 2 + it + 1 == k ){
                cate = it;
                break;
            }
            m1 -= 2;
        }

        if(cate == INT_MAX){
            cout << "NO" << endl;
            continue;
        }

        //cout << "punem de la inceput " << cate << endl;

        int it = 0;
        if(cate > 0){
            for(int i = 0; i < cate; i++){
                if(i % 2 == 0) it++;
                v[0][i] = it;
                v[1][i] = it;
            }
            for(int i = 0; i < cate; i++){
                if(i % 2 == 0) it++;
                v[2][i] = it;
                v[3][i] = it;
            }
        }
        it++;
        for(int i = cate; i < m; i++){
            v[0][i] = it;
            v[3][i] = it;
        }
        v[1][cate] = it;
        v[2][cate] = it;

        v[1][m - 1] = it;
        v[2][m - 1] = it;

        for(int i = cate + 1; i < m - 1; i++){
            //cout << "i = " << i << " it = " << it << endl;
            if( (i - (cate + 1)) % 2 == 0 ) it++;
            v[1][i] = it;
            v[2][i] = it;
        }

        cout << "YES" << endl;
        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 101 ms 828 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 101 ms 828 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 101 ms 828 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 344 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 348 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 101 ms 828 KB Incorrect output
2 Halted 0 ms 0 KB -