Submission #871847

# Submission time Handle Problem Language Result Execution time Memory
871847 2023-11-11T17:54:12 Z Mr_Ph Gardening (RMI21_gardening) C++14
11 / 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
    {
        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
        {
            int cnt=0;
            cnt=2;
            int ans[n][m];
            int am=-1;
            int curn=n-2,curm=m;
            for(int i=0;i<m;i+=2)
            {
                curm-=2;
                ans[0][i]=cnt;
                ans[0][i+1]=cnt;
                ans[1][i]=cnt;
                ans[1][i+1]=cnt;
                cnt++;
                ans[2][i]=cnt;
                ans[2][i+1]=cnt;
                ans[3][i]=cnt;
                ans[3][i+1]=cnt;
                cnt++;
                k-=2;
                if(curm==2)continue;
                if((k)==((curn*(curm-2)/4)+1))
                {
                    am=i+2;
                    break;
                }
            }
            if(am==-1)
            {
                cout<<"NO"<<endl;
                return;
            }
            cout<<"YES"<<endl;
            for(int i=am+1;i<m-1;i+=2)
            {
                ans[1][i]=cnt;
                ans[2][i+1]=cnt;
                ans[1][i+1]=cnt;
                ans[2][i]=cnt;
                cnt++;
            }
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    if((i==0&&j>=am)||(j==am)||(i==3&&j>=am)||(j==m-1&&j>=am))
                        cout<<1<<" ";
                    else cout<<ans[i][j]-(am==m)<<" ";
                }
                cout<<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();
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 860 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 13 ms 860 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 13 ms 860 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
4 Failed 5 ms 604 KB Incorrect output
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Expected int32, but "140722709300672" found
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 Correct 13 ms 860 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 604 KB Correct! Azusa and Laika like the garden :)
4 Failed 5 ms 604 KB Incorrect output
5 Halted 0 ms 0 KB -