Submission #168710

#TimeUsernameProblemLanguageResultExecution timeMemory
168710ho94949Cultivation (JOI17_cultivation)C++17
5 / 100
910 ms504 KiB
#include<bits/stdc++.h> using namespace std; uint64_t B[41]; int main() { int R, C, N; scanf("%d%d%d", &R, &C, &N); assert(R<=40&&C<=40); 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) { if(w+e>=C || n+s>=R) continue; uint64_t A[41]; memcpy(A, B, sizeof A); uint64_t tar = (1ull<<C)-1; for(int i=0; i<w; ++i) for(int j=0; j<R; ++j) A[j] |= (A[j]>>1)&tar; for(int i=0; i<e; ++i) for(int j=0; j<R; ++j) A[j] |= (A[j]<<1)&tar; 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]; /* 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)

cultivation.cpp: In function 'int main()':
cultivation.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &R, &C, &N);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
cultivation.cpp:11:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int u, v; scanf("%d%d", &u, &v);
                   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...