Submission #646811

# Submission time Handle Problem Language Result Execution time Memory
646811 2022-09-30T18:19:07 Z ovidiush11 Gardening (RMI21_gardening) C++14
5 / 100
123 ms 624 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

void draw(ll n,ll m,ll k)
{
    for(ll i = 0;i < k;i++)
    {
        for(ll j = 0;j < i;j++)cout<<j+1<<" ";
        for(ll j = i;j < m-i;j++)cout<<i+1<<" ";
        for(ll j = m-i;j < m;j++)cout<<m-j<<" ";
        cout<<endl;
    }
    ll x = k + 1,y = x,st = 0;
    for(ll i = k;i < n - k;i++)
    {
        for(ll j = 0;j < k;j++)cout<<j+1<<" ";
        for(ll j = k;j < m - k;j+=2)
        {
            cout<<x<<" "<<x<<" ";
            x++;
        }
        for(ll j = m-k;j < m;j++)cout<<m-j<<" ";
        cout<<endl;
        if(st == 0)
        {
            st++;
            x = y;
        }
        else
        {
            st--;
            y = x;
        }
    }
    for(ll i = k-1;i >= 0;i--)
    {
        for(ll j = 0;j < i;j++)cout<<j+1<<" ";
        for(ll j = i;j < m-i;j++)cout<<i+1<<" ";
        for(ll j = m-i;j < m;j++)cout<<m-j<<" ";
        cout<<endl;
    }
    return ;
}

void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    if(n % 2 == 1 || m % 2 == 1)
    {
        cout<<"NO"<<endl;
        return ;
    }
    ll s = -1;
    for(ll i = 0;i < min(n,m) / 2;i++)
    {
        ll x = (n * m - 2 * i * (n + m) + pow(2 * i,2)) / 4 + i;
        if(x == k)
        {
            s = i;
            break;
        }
        else if(x < k)break;
    }
    if(s == -1)cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        draw(n,m,s);
    }
    return ;
}

int main()
{
    ll t;
    cin>>t;
    while(t--)solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 123 ms 624 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 123 ms 624 KB Correct! Azusa and Laika like the garden :)
2 Failed 17 ms 564 KB Incorrect output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 123 ms 624 KB Correct! Azusa and Laika like the garden :)
2 Failed 17 ms 564 KB Incorrect output
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 2 ms 212 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 212 KB Incorrect output
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 123 ms 624 KB Correct! Azusa and Laika like the garden :)
2 Failed 17 ms 564 KB Incorrect output
3 Halted 0 ms 0 KB -