답안 #1067009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067009 2024-08-20T09:37:04 Z heeew Gardening (RMI21_gardening) C++14
100 / 100
17 ms 5392 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 || (n==m && k==n/2+1))
            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 17 ms 5392 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 5392 KB Correct! Azusa and Laika like the garden :)
2 Correct 10 ms 1368 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 1628 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 5392 KB Correct! Azusa and Laika like the garden :)
2 Correct 10 ms 1368 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 1628 KB Correct! Azusa and Laika like the garden :)
4 Correct 8 ms 1624 KB Correct! Azusa and Laika like the garden :)
5 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1472 KB Correct! Azusa and Laika like the garden :)
2 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
3 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
4 Correct 7 ms 1368 KB Correct! Azusa and Laika like the garden :)
5 Correct 5 ms 1372 KB Correct! Azusa and Laika like the garden :)
6 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
7 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
8 Correct 6 ms 1116 KB Correct! Azusa and Laika like the garden :)
9 Correct 6 ms 1368 KB Correct! Azusa and Laika like the garden :)
10 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
11 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
12 Correct 5 ms 1372 KB Correct! Azusa and Laika like the garden :)
13 Correct 5 ms 1116 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
2 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
3 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
4 Correct 4 ms 856 KB Correct! Azusa and Laika like the garden :)
5 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
6 Correct 3 ms 712 KB Correct! Azusa and Laika like the garden :)
7 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
8 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
9 Correct 3 ms 856 KB Correct! Azusa and Laika like the garden :)
10 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
11 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
12 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
13 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
14 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
15 Correct 4 ms 604 KB Correct! Azusa and Laika like the garden :)
16 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
17 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 5392 KB Correct! Azusa and Laika like the garden :)
2 Correct 10 ms 1368 KB Correct! Azusa and Laika like the garden :)
3 Correct 7 ms 1628 KB Correct! Azusa and Laika like the garden :)
4 Correct 8 ms 1624 KB Correct! Azusa and Laika like the garden :)
5 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
6 Correct 7 ms 1472 KB Correct! Azusa and Laika like the garden :)
7 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
8 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
9 Correct 7 ms 1368 KB Correct! Azusa and Laika like the garden :)
10 Correct 5 ms 1372 KB Correct! Azusa and Laika like the garden :)
11 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
12 Correct 7 ms 1372 KB Correct! Azusa and Laika like the garden :)
13 Correct 6 ms 1116 KB Correct! Azusa and Laika like the garden :)
14 Correct 6 ms 1368 KB Correct! Azusa and Laika like the garden :)
15 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
16 Correct 6 ms 1372 KB Correct! Azusa and Laika like the garden :)
17 Correct 5 ms 1372 KB Correct! Azusa and Laika like the garden :)
18 Correct 5 ms 1116 KB Correct! Azusa and Laika like the garden :)
19 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
20 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
21 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
22 Correct 4 ms 856 KB Correct! Azusa and Laika like the garden :)
23 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
24 Correct 3 ms 712 KB Correct! Azusa and Laika like the garden :)
25 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
26 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
27 Correct 3 ms 856 KB Correct! Azusa and Laika like the garden :)
28 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
29 Correct 2 ms 604 KB Correct! Azusa and Laika like the garden :)
30 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
31 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
32 Correct 3 ms 860 KB Correct! Azusa and Laika like the garden :)
33 Correct 4 ms 604 KB Correct! Azusa and Laika like the garden :)
34 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
35 Correct 3 ms 604 KB Correct! Azusa and Laika like the garden :)
36 Correct 9 ms 1628 KB Correct! Azusa and Laika like the garden :)
37 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
38 Correct 9 ms 1628 KB Correct! Azusa and Laika like the garden :)
39 Correct 9 ms 1880 KB Correct! Azusa and Laika like the garden :)
40 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
41 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
42 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
43 Correct 9 ms 1880 KB Correct! Azusa and Laika like the garden :)
44 Correct 8 ms 1680 KB Correct! Azusa and Laika like the garden :)
45 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
46 Correct 8 ms 1624 KB Correct! Azusa and Laika like the garden :)
47 Correct 9 ms 1880 KB Correct! Azusa and Laika like the garden :)
48 Correct 9 ms 1900 KB Correct! Azusa and Laika like the garden :)
49 Correct 8 ms 1884 KB Correct! Azusa and Laika like the garden :)
50 Correct 12 ms 1916 KB Correct! Azusa and Laika like the garden :)
51 Correct 8 ms 1624 KB Correct! Azusa and Laika like the garden :)
52 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
53 Correct 9 ms 1884 KB Correct! Azusa and Laika like the garden :)
54 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
55 Correct 8 ms 1628 KB Correct! Azusa and Laika like the garden :)
56 Correct 8 ms 1880 KB Correct! Azusa and Laika like the garden :)
57 Correct 8 ms 1884 KB Correct! Azusa and Laika like the garden :)
58 Correct 9 ms 1880 KB Correct! Azusa and Laika like the garden :)
59 Correct 9 ms 1880 KB Correct! Azusa and Laika like the garden :)
60 Correct 8 ms 1884 KB Correct! Azusa and Laika like the garden :)