Submission #610252

#TimeUsernameProblemLanguageResultExecution timeMemory
610252DJ035Dango Maker (JOI18_dango_maker)C++17
100 / 100
218 ms19060 KiB
#include <bits/stdc++.h> #define MEM 3333 #define sanic ios_base::sync_with_stdio(0) #define x first #define y second #define pf push_front #define pb push_back #define all(v) v.begin(), v.end() #define sz size() using namespace std; typedef long long ll; typedef pair<ll, ll> pi; const ll INF = 1e18; const ll MOD = 20070713; ll t,n,m,k; char mp[MEM][MEM]; ll dp[MEM][3]; signed main(){ sanic; cin.tie(0); cin >> n >> m; for(int i=1; i<=n; i++) for(int j=1; j<=m; j++) cin >> mp[i][j]; ll ans=0; for(ll i=2; i<=n+m; i++){ memset(dp, 0, sizeof(dp)); for(ll j=max(0LL, i-n); j<=min(m, i-1); j++){ ll k=i-j; dp[j][0] = max({dp[j-1][0], dp[j-1][1], dp[j-1][2]}); if(mp[k-1][j]=='R' && mp[k][j]=='G' && mp[k+1][j]=='W') dp[j][1] = max(dp[j-1][0], dp[j-1][1])+1; if(mp[k][j-1]=='R' && mp[k][j]=='G' && mp[k][j+1]=='W') dp[j][2] = max(dp[j-1][0], dp[j-1][2])+1; } ans += max({dp[min(m, i-1)][0], dp[min(m, i-1)][1], dp[min(m, i-1)][2]}); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...