이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |