Submission #953550

#TimeUsernameProblemLanguageResultExecution timeMemory
953550Darren0724Cultivation (JOI17_cultivation)C++17
5 / 100
2086 ms456 KiB
#include <bits/stdc++.h> using namespace std; #define LCBorz ios_base::sync_with_stdio(false); cin.tie(0); #define all(x) x.begin(), x.end() #define endl '\n' const int N=42; const int INF=1e9; vector v(N,vector(N,0)); vector<int> dx={1,-1,0,0},dy={0,0,1,-1}; int r,c; int solve(vector<int> a){ vector v1=v; vector v2=v; for(int k=0;k<4;k++){ for(int times=0;times<a[k];times++){ for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ int c=i+dx[k]; int d=j+dy[k]; if(v1[i][j])v2[c][d]=1; } } v1=v2; } } int cnt=0; for(int i=1;i<=r;i++){ for(int j=1;j<=c;j++){ cnt+=v1[i][j]; } } return cnt==r*c; } int32_t main() { LCBorz; cin>>r>>c; int n;cin>>n; vector<int> a(n),b(n); for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; v[a[i]][b[i]]=1; } int ans=INF; for(int i=0;i<r;i++){ for(int j=0;j<r;j++){ for(int k=0;k<c;k++){ for(int l=0;l<c;l++){ if(solve({i,j,k,l})){ ans=min(ans,i+j+k+l); } } } } } cout<<ans<<endl; return 0; }
#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...