답안 #871840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871840 2023-11-11T17:24:24 Z Mr_Ph Gardening (RMI21_gardening) C++14
0 / 100
13 ms 860 KB
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
ll mod=(ll)1e9+7;
ll mod1=998244353;
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
#define int long long
void preprocess() {}
void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    bool lmao=false;
    if(n>m)
    {
        swap(n,m);
        lmao=true;
    }
    if((n*m)/4<k||n%2||m%2)
        cout<<"NO"<<endl;
    else if(n==2)
    {
        if(k!=(m/2))
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            if(!lmao)
            {
                for(int i=0; i<2; i++)
                {
                    int x=1;
                    for(int j=0; j<m; j+=2)
                    {
                        cout<<x<<" "<<x<<" ";
                        x++;
                    }
                    cout<<endl;
                }
            }
            else
            {
                int x=1;
                for(int i=0; i<m; i+=2)
                {
                    cout<<x<<" "<<x<<endl;
                    cout<<x<<" "<<x<<endl;
                    x++;
                }
            }
        }
    }
    else
    {
        if(k==(n*m)/4)
        {
            cout<<"Yes"<<endl;
            int ans[n][m];
            int x=1;
            for(int i=0; i<n; i+=2)
            {
                for(int j=0; j<m; j+=2)
                {
                    ans[i][j]=x;
                    ans[i+1][j]=x;
                    ans[i+1][j+1]=x;
                    ans[i][j+1]=x;
                    x++;
                }
            }
            for(int i=0; i<n; i++)
            {
                for(int j=0; j<m; j++)
                    cout<<ans[i][j]<<" ";
                cout<<endl;
            }
        }
        else
        {
            int nn=n-2,mm=m-2;
            if((k)==((nn*mm/4)+1))
            {
                cout<<"YES"<<endl;
                int ans[n][m];
                int x=2;
                for(int i=1; i<m-1; i+=2)
                {
                    ans[1][i]=x;
                    ans[2][i+1]=x;
                    ans[1][i+1]=x;
                    ans[2][i]=x;
                    x++;
                }
                for(int i=0; i<n; i++)
                {
                    for(int j=0; j<m; j++)
                    {
                        if(i==0||j==0||i==n-1||j==m-1)
                            cout<<1<<" ";
                        else
                            cout<<ans[i][j]<<" ";
                    }
                    cout<<endl;
                }
            }
            else
                cout<<"NO"<<endl;
        }
    }
}
signed main()
{
    // freopen("meta_game_input.txt","r",stdin);
    // freopen("otput.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    preprocess();
    //bla();
    int t=1;
    cin>>t;
    while(t--)
        solve();
}
# 결과 실행 시간 메모리 Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 348 KB Incorrect output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 0 ms 348 KB Incorrect output
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 13 ms 860 KB Incorrect output
2 Halted 0 ms 0 KB -