Submission #201342

#TimeUsernameProblemLanguageResultExecution timeMemory
201342abilDango Maker (JOI18_dango_maker)C++14
13 / 100
5 ms380 KiB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (3e3 + 12);
const int mod = (1e9 + 7);
const int inf = (1e9 + 7);

int dp[N][N];
char a[N][N];

main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			scanf(" %c", &a[i][j]);
		}
	}
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			int x = 0, y = 0;
			if(j >= 3){
				if(a[i][j] == 'W' && a[i][j - 1] == 'G' && a[i][j - 2] == 'R'){
					y++;
				}
			}
			if(i >= 3){
				if(a[i][j] == 'W' && a[i - 1][j] == 'G' && a[i - 2][j] == 'R'){
					x++;
				}
			}
			dp[i][j] = max(dp[i - 1][j] + x + dp[i][j - 1] - dp[i - 1][j - 1], dp[i][j - 1] + y + dp[i - 1][j] - dp[i - 1][j - 1]);
		}
	}
	int cnt = 0;
	for(int i = 1;i <= n; i++){
		for(int j = 1;j <= m; j++){
			if(a[i][j] == 'R' && a[i][j + 1] == 'G' && a[i][j + 2] == 'W' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W'){
				cnt++;
			}
		}
	}
	cout << dp[n][m] - cnt;
}

Compilation message (stderr)

dango_maker.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:24:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c", &a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...