답안 #1112800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112800 2024-11-14T21:19:52 Z snpmrnhlol Gardening (RMI21_gardening) C++17
100 / 100
62 ms 1176 KB
#include<bits/stdc++.h>
using namespace std;
vector <vector<int>> ans;
bool check(int n, int m, int k){
    ///checks if (n, m, k) is true
    ///works for like 99% of cases
    ///(i hope)
    if(n > m)swap(n, m);
    if(n%2 == 1 || m%2 == 1)return 0;
    if(n == m && k == n/2 + 1)return 0;
    ///i sense a pattern and so i bullshit
    int l = max(n, m)/2, r = n*m/4;
    return l <= k && k <= r && k != r - 1;
}
int colcnt;
void constructsol(int n, int m, int k, int dx, int dy){
    if(n == 0 || m == 0)return;
    if(!check(n, m, k))return;
    ///idk what to do lol
    ///im trying like 3 cases
    if(check(n, m - 2, k - n/2)){
        constructsol(n, m - 2, k - n/2, dx, dy);
        for(int i = 0;i < n;i+=2){
            ans[i + dx][m - 2 + dy] = colcnt;
            ans[i + dx][m - 1 + dy] = colcnt;
            ans[i + 1 + dx][m - 2 + dy] = colcnt;
            ans[i + 1 + dx][m - 1 + dy] = colcnt;
            colcnt++;
        }
    }else if(check(n - 2, m, k - m/2)){
        constructsol(n - 2, m, k - m/2, dx, dy);
        for(int j = 0;j < m;j+=2){
            ans[n - 2 + dx][j + dy] = colcnt;
            ans[n - 2 + dx][j + 1 + dy] = colcnt;
            ans[n - 1 + dx][j + dy] = colcnt;
            ans[n - 1 + dx][j + 1 + dy] = colcnt;
            colcnt++;
        }
    }else if(check(n - 2, m - 2, k - 1)){
        constructsol(n - 2, m - 2, k - 1, dx + 1, dy + 1);
        for(int i = 0;i < n;i++){
            ans[i + dx][0 + dy] = colcnt;
            ans[i + dx][m - 1 + dy] = colcnt;
        }
        for(int i = 0;i < m;i++){
            ans[0 + dx][i + dy] = colcnt;
            ans[n - 1 + dx][i + dy] = colcnt;
        }
        colcnt++;
    }
}
void solve(){
    int n, m, k;
    cin>>n>>m>>k;
    ///I REALLY HATE MY LIFE
    ans.assign(n, vector<int>(m, 0));
    colcnt = 1;
    if(check(n, m, k)){
        cout<<"YES\n";
        constructsol(n, m, k, 0, 0);
        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++){
                cout<<ans[i][j]<<' ';
            }
            cout<<'\n';
        }
    }else{
        cout<<"NO\n";
    }
}
int main(){
    //ios_base::sync_with_stdio(0);
    //cin.tie(0);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 840 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 840 KB Correct! Azusa and Laika like the garden :)
2 Correct 14 ms 592 KB Correct! Azusa and Laika like the garden :)
3 Correct 14 ms 708 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 840 KB Correct! Azusa and Laika like the garden :)
2 Correct 14 ms 592 KB Correct! Azusa and Laika like the garden :)
3 Correct 14 ms 708 KB Correct! Azusa and Laika like the garden :)
4 Correct 12 ms 592 KB Correct! Azusa and Laika like the garden :)
5 Correct 12 ms 696 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 592 KB Correct! Azusa and Laika like the garden :)
2 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
3 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
4 Correct 9 ms 592 KB Correct! Azusa and Laika like the garden :)
5 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
6 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
7 Correct 9 ms 592 KB Correct! Azusa and Laika like the garden :)
8 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
9 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
10 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
11 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
12 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
13 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
2 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
3 Correct 4 ms 760 KB Correct! Azusa and Laika like the garden :)
4 Correct 5 ms 592 KB Correct! Azusa and Laika like the garden :)
5 Correct 6 ms 592 KB Correct! Azusa and Laika like the garden :)
6 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
7 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
8 Correct 5 ms 480 KB Correct! Azusa and Laika like the garden :)
9 Correct 5 ms 672 KB Correct! Azusa and Laika like the garden :)
10 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
11 Correct 3 ms 508 KB Correct! Azusa and Laika like the garden :)
12 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
13 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
14 Correct 7 ms 760 KB Correct! Azusa and Laika like the garden :)
15 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
16 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
17 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 840 KB Correct! Azusa and Laika like the garden :)
2 Correct 14 ms 592 KB Correct! Azusa and Laika like the garden :)
3 Correct 14 ms 708 KB Correct! Azusa and Laika like the garden :)
4 Correct 12 ms 592 KB Correct! Azusa and Laika like the garden :)
5 Correct 12 ms 696 KB Correct! Azusa and Laika like the garden :)
6 Correct 11 ms 592 KB Correct! Azusa and Laika like the garden :)
7 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
8 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
9 Correct 9 ms 592 KB Correct! Azusa and Laika like the garden :)
10 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
11 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
12 Correct 9 ms 592 KB Correct! Azusa and Laika like the garden :)
13 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
14 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
15 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
16 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
17 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
18 Correct 8 ms 592 KB Correct! Azusa and Laika like the garden :)
19 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
20 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
21 Correct 4 ms 760 KB Correct! Azusa and Laika like the garden :)
22 Correct 5 ms 592 KB Correct! Azusa and Laika like the garden :)
23 Correct 6 ms 592 KB Correct! Azusa and Laika like the garden :)
24 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
25 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
26 Correct 5 ms 480 KB Correct! Azusa and Laika like the garden :)
27 Correct 5 ms 672 KB Correct! Azusa and Laika like the garden :)
28 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
29 Correct 3 ms 508 KB Correct! Azusa and Laika like the garden :)
30 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
31 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
32 Correct 7 ms 760 KB Correct! Azusa and Laika like the garden :)
33 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
34 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
35 Correct 4 ms 592 KB Correct! Azusa and Laika like the garden :)
36 Correct 13 ms 848 KB Correct! Azusa and Laika like the garden :)
37 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
38 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
39 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
40 Correct 12 ms 848 KB Correct! Azusa and Laika like the garden :)
41 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
42 Correct 10 ms 848 KB Correct! Azusa and Laika like the garden :)
43 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
44 Correct 13 ms 848 KB Correct! Azusa and Laika like the garden :)
45 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
46 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
47 Correct 12 ms 848 KB Correct! Azusa and Laika like the garden :)
48 Correct 12 ms 848 KB Correct! Azusa and Laika like the garden :)
49 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
50 Correct 12 ms 848 KB Correct! Azusa and Laika like the garden :)
51 Correct 11 ms 1020 KB Correct! Azusa and Laika like the garden :)
52 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
53 Correct 12 ms 1176 KB Correct! Azusa and Laika like the garden :)
54 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
55 Correct 10 ms 856 KB Correct! Azusa and Laika like the garden :)
56 Correct 11 ms 888 KB Correct! Azusa and Laika like the garden :)
57 Correct 11 ms 756 KB Correct! Azusa and Laika like the garden :)
58 Correct 11 ms 848 KB Correct! Azusa and Laika like the garden :)
59 Correct 11 ms 1044 KB Correct! Azusa and Laika like the garden :)
60 Correct 12 ms 848 KB Correct! Azusa and Laika like the garden :)