# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66885 | hamzqq9 | Dango Maker (JOI18_dango_maker) | C++14 | 838 ms | 154684 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 100000000000000
#define MOD 1000000007
#define N 3005
#define MAX 10000006
#define LOG 22
using namespace std;
int n,m,ans;
int dp[N][N][2],node[N][N][2];
char a[N][N];
int main() {
//freopen("input.txt","r",stdin);
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
scanf(" %c",&a[i][j]);
}
}
// 0 vertical 1 horizontal
for(int i=1;i<=n;i++) {
if(i>1 && i<n) {
for(int j=1;j<=m;j++) {
if(a[i-1][j]=='R' && a[i][j]=='G' && a[i+1][j]=='W') node[i][j][0]=1;
}
}
for(int j=2;j<=m;j++) {
if(a[i][j-1]=='R' && a[i][j]=='G' && a[i][j+1]=='W') node[i][j][1]=1;
}
}
for(int i=n;i>=1;i--) {
for(int j=1;j<=m;j++) {
dp[i][j][0]=max(dp[i+1][j-1][1],dp[i+1][j-1][0]+node[i][j][0]);
dp[i][j][1]=max(dp[i+1][j-1][0],dp[i+1][j-1][1]+node[i][j][1]);
}
}
for(int i=1;i<=m;i++) ans+=max(dp[1][i][0],dp[1][i][1]);
for(int i=2;i<=n;i++) ans+=max(dp[i][m][0],dp[i][m][1]);
printf("%d",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |