Submission #1220151

#TimeUsernameProblemLanguageResultExecution timeMemory
1220151Theo830UFO (IZhO14_ufo)C++20
35 / 100
2095 ms8260 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define id pair<ll,vector<ll> > #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training int main(void){ ios_base::sync_with_stdio(0); cin.tie(0); ll n,m,r,k,p; cin>>n>>m>>r>>k>>p; ll ans = 0; ll arr[n][m]; f(i,0,n){ f(j,0,m){ cin>>arr[i][j]; } } while(k--){ char c; cin>>c; ll i,h; cin>>i>>h; i--; ll r2 = r; if(c == 'W'){ for(ll j = 0;j < m && r2 > 0;j++){ if(arr[i][j] >= h){ arr[i][j]--; r2--; } } } else if(c == 'E'){ for(ll j = m-1;j >=0 && r2 > 0;j--){ if(arr[i][j] >= h){ arr[i][j]--; r2--; } } } else if(c == 'N'){ for(ll j = 0;j < n && r2 > 0;j++){ if(arr[j][i] >= h){ arr[j][i]--; r2--; } } } else{ for(ll j = n-1;j >= 0 && r2 > 0;j--){ if(arr[j][i] >= h){ arr[j][i]--; r2--; } } } } f(i,0,n-p+1){ f(j,0,m-p+1){ ll res = 0; f(x,i,i+p){ f(y,j,j+p){ res += arr[x][y]; } } ans = max(ans,res); } } cout<<ans<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...