답안 #201342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201342 2020-02-10T08:39:42 Z abil Dango Maker (JOI18_dango_maker) C++14
13 / 100
5 ms 380 KB
#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

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]);
    ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Incorrect 5 ms 376 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Incorrect 5 ms 376 KB Output isn't correct
18 Halted 0 ms 0 KB -