답안 #522368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522368 2022-02-04T16:56:22 Z AdamGS Dango Maker (JOI18_dango_maker) C++17
100 / 100
145 ms 89492 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=3e3+7;
string T[LIM];
int ok[LIM][LIM], odw[LIM][LIM];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m;
	cin >> n >> m;
	rep(i, n) cin >> T[i];
	rep(i, n) rep(j, m) if(T[i][j]=='G') {
		if(i && i<n-1 && T[i-1][j]=='R' && T[i+1][j]=='W') ok[i][j]|=1;
		if(j && j<m-1 && T[i][j-1]=='R' && T[i][j+1]=='W') ok[i][j]|=2;
	}
	int ans=0;
	rep(i, n) rep(j, m) if(ok[i][j] && !odw[i][j]) {
		odw[i][j]=1;
		int dp[2][3];
		dp[1][0]=dp[1][1]=dp[1][2]=0;
		if(ok[i][j]&1) ++dp[1][1];
		if(ok[i][j]&2) ++dp[1][2];
		int a=i, b=j;
		while(a<n-1) {
			++a;
			if(b && (ok[a-1][b]|ok[a][b-1])==3) --b;
			else if(b<m-1 && (ok[a-1][b]|ok[a][b+1])==3) ++b;
			else break;
			odw[a][b]=1;
			rep(l, 3) {
				dp[0][l]=dp[1][l];
				dp[1][l]=0;
			}
			dp[1][0]=max(dp[0][0], max(dp[0][1], dp[0][2]));
			if(ok[a][b]&1) dp[1][1]=max(dp[0][0], dp[0][1])+1;
			if(ok[a][b]&2) dp[1][2]=max(dp[0][0], dp[0][2])+1;
		}
		ans+=max(dp[1][0], max(dp[1][1], dp[1][2]));
	}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 412 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 416 KB Output is correct
25 Correct 1 ms 420 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 416 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 408 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 0 ms 416 KB Output is correct
33 Correct 1 ms 416 KB Output is correct
34 Correct 1 ms 412 KB Output is correct
35 Correct 0 ms 460 KB Output is correct
36 Correct 0 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 0 ms 412 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 1 ms 460 KB Output is correct
46 Correct 1 ms 460 KB Output is correct
47 Correct 1 ms 460 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 1 ms 460 KB Output is correct
50 Correct 1 ms 412 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 1 ms 460 KB Output is correct
53 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 412 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 416 KB Output is correct
25 Correct 1 ms 420 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 416 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 408 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 0 ms 416 KB Output is correct
33 Correct 1 ms 416 KB Output is correct
34 Correct 1 ms 412 KB Output is correct
35 Correct 0 ms 460 KB Output is correct
36 Correct 0 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 0 ms 412 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 1 ms 460 KB Output is correct
46 Correct 1 ms 460 KB Output is correct
47 Correct 1 ms 460 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 1 ms 460 KB Output is correct
50 Correct 1 ms 412 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 1 ms 460 KB Output is correct
53 Correct 1 ms 460 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 2 ms 1356 KB Output is correct
56 Correct 1 ms 460 KB Output is correct
57 Correct 7 ms 14668 KB Output is correct
58 Correct 20 ms 18064 KB Output is correct
59 Correct 130 ms 89492 KB Output is correct
60 Correct 145 ms 87804 KB Output is correct
61 Correct 145 ms 87844 KB Output is correct
62 Correct 1 ms 460 KB Output is correct
63 Correct 133 ms 87620 KB Output is correct
64 Correct 112 ms 87812 KB Output is correct
65 Correct 112 ms 87876 KB Output is correct
66 Correct 123 ms 87880 KB Output is correct
67 Correct 72 ms 48940 KB Output is correct
68 Correct 75 ms 48876 KB Output is correct
69 Correct 85 ms 61724 KB Output is correct
70 Correct 20 ms 18252 KB Output is correct
71 Correct 15 ms 18196 KB Output is correct
72 Correct 14 ms 18212 KB Output is correct
73 Correct 18 ms 18280 KB Output is correct
74 Correct 15 ms 18176 KB Output is correct
75 Correct 17 ms 18224 KB Output is correct
76 Correct 15 ms 18228 KB Output is correct
77 Correct 14 ms 18212 KB Output is correct
78 Correct 14 ms 18212 KB Output is correct
79 Correct 15 ms 18168 KB Output is correct
80 Correct 16 ms 18188 KB Output is correct
81 Correct 22 ms 18164 KB Output is correct
82 Correct 15 ms 18164 KB Output is correct
83 Correct 15 ms 18196 KB Output is correct
84 Correct 15 ms 18192 KB Output is correct
85 Correct 20 ms 18192 KB Output is correct
86 Correct 15 ms 18176 KB Output is correct
87 Correct 15 ms 18168 KB Output is correct
88 Correct 14 ms 18216 KB Output is correct
89 Correct 13 ms 18208 KB Output is correct
90 Correct 13 ms 18244 KB Output is correct