답안 #1066991

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1066991 2024-08-20T09:23:14 Z 정희우(#11124) Gardening (RMI21_gardening) C++17
11 / 100
200 ms 5140 KB
#include<iostream>
#include<algorithm>
#include<vector>

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

const int CUTLINE=4500;
const int MAX_N=200010;

vint ans;
vint ns,ms;
vector<vector<vint>> a;

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++)
            a.back()[i][j]=c;
}

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

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T;
    cin >> T;
    ans.resize(T);
    ns.resize(T);
    ms.resize(T);
    for(int t=0;t<T;t++)
    {
        int n,m,k;
        cin >> n >> m >> k;
        a.push_back({});
        if(n%2 || m%2)
            continue;
        if(k>n*m/4 || k==n*m/4-1 || k<max(n,m)/2)
            continue;
        ans[t]=1,ns[t]=n,ms[t]=m;
        a.back().resize(n);
        for(int i=0;i<n;i++)
            a.back()[i].resize(m);
        fillmp(0,n,0,m,k);
    }
    for(int t=0;t<T;t++)
    {
        if(!ans[t])
        {
            cout << "NO\n";
            continue;
        }
        cout << "YES\n";
        int n=ns[t],m=ms[t];
        for(int i=0;i<n;i++,cout << '\n')
            for(int j=0;j<m;j++)
                cout << a[t][i][j] << ' ';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 5140 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 5140 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 5140 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
4 Execution timed out 1042 ms 348 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1020 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1043 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 5140 KB Correct! Azusa and Laika like the garden :)
2 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
4 Execution timed out 1042 ms 348 KB Time limit exceeded
5 Halted 0 ms 0 KB -