제출 #289945

#제출 시각아이디문제언어결과실행 시간메모리
289945keta_tsimakuridzeT-Covering (eJOI19_covering)C++14
5 / 100
411 ms10632 KiB
#include<bits/stdc++.h> #define pii pair<int,int> #define f first #define s second using namespace std; int a[1005][1005],n,m,k,i,x,y,F[1005][1005],ans,mx,f,ff; bool ok(pair<int,int>p){ int x=p.f; int y=p.s; if(x<1 || x>n || y<1 || y>m) return 0; return 1; } int main(){ cin>>n>>m; for(k=1;k<=n;k++){ for(i=1;i<=m;i++){ cin>>a[k][i]; } } cin>>k; while(k--){ cin>>x>>y; x++;y++; F[x][y]=1; } for(k=1;k<=n;k++){ for(i=1;i<=m;i++){ if(!F[k][i]) continue; pii zeda={k-1,i}; pii kveda={k+1,i}; pii marj={k,i+1}; pii marc={k,i-1}; mx=0; f=0; if(ok(zeda) && ok(marc) && ok(marj)) { //cout<<"1"; f=1; mx=a[k][i]+a[zeda.f][zeda.s]+a[marc.f][marc.s]+a[marj.f][marj.s]; } if(ok(zeda) && ok(marc) && ok(kveda)) {f=1; mx=max(mx,a[k][i]+a[zeda.f][zeda.s]+a[marc.f][marc.s]+a[kveda.f][kveda.s]); } if(ok(zeda) && ok(kveda) && ok(marj)) {f=1; mx=max(mx,a[k][i]+a[zeda.f][zeda.s]+a[kveda.f][kveda.s]+a[marj.f][marj.s]); } if(ok(kveda) && ok(marc) && ok(marj)) {f=1; mx=max(mx,a[k][i]+a[kveda.f][kveda.s]+a[marc.f][marc.s]+a[marj.f][marj.s]); } ans+=mx; if(!f)ff=1; } } if(ff) cout<<"No";else cout<<ans; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...