답안 #170253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170253 2019-12-24T11:34:39 Z ZwariowanyMarcin Dango Maker (JOI18_dango_maker) C++14
100 / 100
441 ms 164728 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)

using namespace std;	

const int nax = 3111;

void maxi(int &a, int b) {
	a = max(a, b);
}

int n, m;
char s[nax][nax];

bool in(int r, int c) {
	return 1 <= r && r <= n && 1 <= c && c <= m;
}

int dp[nax][nax][2][2];

int daj(int r, int c) {
	int naj = 0;
	for(int i = 0; i < 2; ++i)
		for(int j = 0; j < 2; ++j)
			maxi(naj, dp[r][c][i][j]);
	return naj;
}

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i) 
		scanf("%s", s[i] + 1);
	for(int r = 1; r <= n; ++r) 
		for(int c = m; 1 <= c; --c) 
			for(int g = 0; g < 2; ++g)
				for(int d = 0; d < 2; ++d) {
					maxi(dp[r][c][0][0], dp[r - 1][c + 1][g][d]);
					if(!(s[r][c] == 'G')) continue;
					
					if(in(r - 1, c) && s[r - 1][c] == 'R' && g == 0) 
						if(in(r + 1, c) && s[r + 1][c] == 'W')
							maxi(dp[r][c][0][1], dp[r - 1][c + 1][g][d] + 1);
					
					if(in(r, c + 1) && s[r][c + 1] == 'W' && d == 0)	
						if(in(r, c - 1) && s[r][c - 1] == 'R')
							maxi(dp[r][c][1][0], dp[r - 1][c + 1][g][d] + 1);
				}
	int ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j) 
			if(i == n || j == 1) 
				ans += daj(i, j);
	printf("%d\n", ans);
			
	
	
	
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:37: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:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", s[i] + 1);
   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 400 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 380 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 3 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 400 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 380 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 3 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 2 ms 376 KB Output is correct
55 Correct 23 ms 21752 KB Output is correct
56 Correct 3 ms 636 KB Output is correct
57 Correct 17 ms 14840 KB Output is correct
58 Correct 57 ms 24056 KB Output is correct
59 Correct 441 ms 164520 KB Output is correct
60 Correct 439 ms 164472 KB Output is correct
61 Correct 438 ms 164728 KB Output is correct
62 Correct 2 ms 504 KB Output is correct
63 Correct 435 ms 164048 KB Output is correct
64 Correct 405 ms 164516 KB Output is correct
65 Correct 392 ms 164436 KB Output is correct
66 Correct 391 ms 164600 KB Output is correct
67 Correct 366 ms 164368 KB Output is correct
68 Correct 380 ms 164472 KB Output is correct
69 Correct 381 ms 164528 KB Output is correct
70 Correct 52 ms 24056 KB Output is correct
71 Correct 51 ms 24028 KB Output is correct
72 Correct 51 ms 24016 KB Output is correct
73 Correct 51 ms 24056 KB Output is correct
74 Correct 51 ms 24028 KB Output is correct
75 Correct 51 ms 24056 KB Output is correct
76 Correct 52 ms 24056 KB Output is correct
77 Correct 51 ms 24184 KB Output is correct
78 Correct 51 ms 24056 KB Output is correct
79 Correct 51 ms 24060 KB Output is correct
80 Correct 51 ms 24056 KB Output is correct
81 Correct 51 ms 24056 KB Output is correct
82 Correct 51 ms 24056 KB Output is correct
83 Correct 51 ms 24056 KB Output is correct
84 Correct 51 ms 24056 KB Output is correct
85 Correct 51 ms 24056 KB Output is correct
86 Correct 51 ms 24056 KB Output is correct
87 Correct 51 ms 24056 KB Output is correct
88 Correct 51 ms 24092 KB Output is correct
89 Correct 51 ms 24056 KB Output is correct
90 Correct 51 ms 24056 KB Output is correct