Submission #1066946

# Submission time Handle Problem Language Result Execution time Memory
1066946 2024-08-20T08:59:24 Z 정희우(#11124) Gardening (RMI21_gardening) C++17
11 / 100
200 ms 856 KB
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using lint = long long;
using vint = vector<int>;
using pii = pair<int,int>;

vector<vint> mp;

void sqr(int s,int e,int l,int r,int c)
{
    for(int i=s;i<e;i++)
        for(int j=l;j<r;j++)
            mp[i][j]=c;
}

void fillmp(int s,int e,int l,int r,int c)
{
    int n=(e-s)/2,m=(r-l)/2;
    if(c==n*m)
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                sqr(s+i*2,s+i*2+2,l+j*2,l+j*2+2,c--);
    }
    else if(c-1<=(n-1)*(m-1)-2 || c-1==(n-1)*(m-1))
    {
        sqr(s,e,l,l+1,c);
        sqr(s,e,r-1,r,c);
        sqr(s,s+1,l,r,c);
        sqr(e-1,e,l,r,c);
        fillmp(s+1,e-1,l+1,r-1,c-1);
    }
    else if(n>m)
    {
        for(int j=0;j<m;j++)
            sqr(s,s+2,l+j*2,l+j*2+2,c--);
        fillmp(s+2,e,l,r,c);
    }
    else
    {
        for(int i=0;i<n;i++)
            sqr(s+i*2,s+i*2+2,l,l+2,c--);
        fillmp(s,e,l+2,r,c);
    }
}

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T;
    cin >> T;
    while(T--)
    {
        int n,m,k;
        cin >> n >> m >> k;
        if(n%2 || m%2)
        {
            cout << "NO\n";
            continue;
        }
        if(k>n*m/4 || k==n*m/4-1 || k<max(n,m)/2)
        {
            cout << "NO\n";
            continue;
        }
        mp.resize(n);
        for(int i=0;i<n;i++)
            mp[i].resize(m);
        fillmp(0,n,0,m,k);
        cout << "YES\n";
        for(int i=0;i<n;i++,cout << '\n')
            for(int j=0;j<m;j++)
                cout << mp[i][j] << ' ';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 856 KB Correct! Azusa and Laika like the garden :)
# Verdict Execution time Memory Grader output
1 Correct 11 ms 856 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 11 ms 856 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 Execution timed out 1029 ms 348 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 856 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 Execution timed out 1029 ms 348 KB Time limit exceeded
5 Halted 0 ms 0 KB -