# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168701 | ho94949 | Cultivation (JOI17_cultivation) | C++17 | 2 ms | 504 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;
int main()
{
uint64_t B[40];
int R, C, N;
scanf("%d%d%d", &R, &C, &N);
for(int i=0; i<N; ++i)
{
int u, v; scanf("%d%d", &u, &v);
B[u-1] |= (1ull<<v-1);
}
int ans = 202020;
for(int w=0; w<C; ++w) for(int e=0; e<C; ++e) for(int n=0; n<R; ++n) for(int s=0; s<R; ++s)
{
uint64_t A[40]; memcpy(A, B, sizeof A);
if(w+e>=C || n+s>=R) continue;
for(int i=0; i<w; ++i)
for(int j=0; j<R; ++j)
A[i] |= A[i]>>1;
for(int i=0; i<e; ++i)
for(int j=0; j<R; ++j)
A[i] |= A[i]<<1;
for(int i=0; i<n; ++i)
for(int j=0; j<R-1; ++j)
A[j] |= A[j+1];
for(int i=0; i<s; ++i)
for(int j=R-2; j>=0; --j)
A[j+1] |= A[j];
uint64_t tar = (1ull<<C)-1;
/*printf("%d %d %d %d\n", w, e, n, s);
for(int i=0; i<R; ++i,puts(""))
for(int j=0; j<C; ++j)
printf("%d", !!(A[i]&(1<<j)));
*/
for(int i=0; i<R; ++i)
tar &= A[i];
if(tar == (1ull<<C)-1)
ans = min(ans, w+e+n+s);
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | 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... |