# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
742831 | hmm789 | Gardening (RMI21_gardening) | C++14 | 21 ms | 724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
vector<vector<int>> a;
int clr = 1;
void solve(int l, int r, int u, int d, int k) {
int n = d-u+1, m = r-l+1;
if(n <= 0 || m <= 0) return;
if(k == n*m/4) {
for(int i = u; i <= d; i++) {
for(int j = l; j <= r; j++) {
if((i-u)%2==0) {
if((j-l)%2==0) a[i][j] = clr;
else a[i][j] = clr++;
} else a[i][j] = a[i-1][j];
}
}
} else if(k >= n*m/4-n/2-m/2+2) {
int num = n*m/4-k;
if(num*2 <= m) {
for(int i = l; i < l+num*2; i++) a[u][i] = a[min(d, u+3)][i] = clr;
for(int i = u; i <= min(d, u+3); i++) a[i][l] = a[i][l+num*2-1] = clr;
clr++;
solve(l+1, l+num*2-2, u+1, min(d, u+3)-1, num-1);
solve(l+num*2, r, u, min(d, u+3), r-(l+num*2)+1);
solve(l, r, min(d, u+3)+1, d, k-1-(num-1)-(r-(l+num*2)+1));
} else {
int cols = (num-m/2)*2+4;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |