Submission #924835

#TimeUsernameProblemLanguageResultExecution timeMemory
924835SalihSahinDango Maker (JOI18_dango_maker)C++17
100 / 100
350 ms19684 KiB
#include<bits/stdc++.h> #define pb push_back #define int long long #define mp make_pair using namespace std; const int mod = 998244353; const int inf = 1e16; const int N = 55; int32_t main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, m; cin>>n>>m; vector<vector<char> > a(n, vector<char>(m)); vector<vector<bool> > vis(n, vector<bool>(m)); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cin>>a[i][j]; } } int ans = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(a[i][j] == 'G' && !vis[i][j]){ vis[i][j] = 1; int cnt = 1; while(i + cnt < n && j - cnt >= 0){ if(a[i + cnt][j - cnt] == 'G'){ vis[i + cnt][j - cnt] = 1; cnt++; } else break; } vector<vector<int> > dp(cnt+1, vector<int>(3)); // 0 = none, 1 = left to right, 2 = up to down for(int k = 1; k <= cnt; k++){ dp[k][0] = max({dp[k-1][0], dp[k-1][1], dp[k-1][2]}); int y = i + (k-1), x = j - (k-1); if(x - 1 >= 0 && x + 1 < m && a[y][x-1] == 'R' && a[y][x+1] == 'W'){ dp[k][1] = max({dp[k-1][0] + 1, dp[k-1][1] + 1}); } if(y - 1 >= 0 && y + 1 < n && a[y-1][x] == 'R' && a[y+1][x] == 'W'){ dp[k][2] = max({dp[k-1][0] + 1, dp[k-1][2] + 1}); } } ans += max({dp[cnt][0], dp[cnt][1], dp[cnt][2]}); } } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...