답안 #824117

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824117 2023-08-13T14:33:08 Z sven Dango Maker (JOI18_dango_maker) C++17
100 / 100
294 ms 35628 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3 * 1000 + 10;

char tab[MAXN][MAXN];
bool peut[MAXN][MAXN][2];
// 0 -> droite 
// 1 -> bas
//
int mod3(int n)
{
	return ((n % 3) + 3) % 3;
}
int main()
{
	ios::sync_with_stdio(false);
	int N , M;
	cin >> N >> M;
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < M ; j++)
		{
			cin >> tab[i][j];
		}
	}
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < M ; j++)
		{
			if (j + 2 < M && tab[i][j] == 'R' && tab[i][j + 1] == 'G' && tab[i][j + 2] == 'W')
			{
				peut[i][j][0] = true;
			}
			if (i + 2 < N && tab[i][j] == 'R' && tab[i + 1][j] == 'G' && tab[i + 2][j] == 'W')
			{
				peut[i][j][1] = true;
			}
		}
	}

	int sol = 0;
	int i0 = 0;
	int j0 = 0;
	while (j0 < M && i0 < N)
	{
		int nb[3];
		nb[0] = nb[1] = nb[2] = 0;
		int ofs = 0;
		int i = i0;
		int j = j0;
		while (i < N && j >= 0)
		{
			int valb = max(nb[ofs] , max(nb[mod3(ofs - 1)] , nb[mod3(ofs - 2)])) + 1;
			int vald = nb[ofs] + 1;
			nb[mod3(ofs - 2)] = max(nb[mod3(ofs - 2)] , nb[ofs]);
			nb[mod3(ofs - 1)] = max(nb[mod3(ofs - 1)] , nb[mod3(ofs - 2)]);
			if (peut[i][j][0])
			{
				nb[mod3(ofs - 2)] = max(nb[mod3(ofs - 2)] , vald);
				nb[mod3(ofs - 1)] = max(nb[mod3(ofs - 1)] , vald);
				nb[mod3(ofs - 0)] = max(nb[mod3(ofs - 0)] , vald);
			}
			if (peut[i][j][1])
			{
				nb[ofs] = valb;
			}
//			if (j0 == 7)
//			{
//				cout<<nb[ofs]<<" "<<nb[mod3(ofs - 1)]<<" "<<nb[mod3(ofs - 2)]<<endl;
//			}
			i++;
			j--;
			ofs = mod3(ofs + 1);
		}
		int aj = max(nb[0] , max(nb[1] , nb[2]));
		sol += aj;
//		cout<<aj<<endl;
		j0++;
		if (j0 == M)
		{
			i0++;
			j0 = M - 1;
		}
	}
	cout<<sol<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 5 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 5 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 5 ms 9556 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 5 ms 13184 KB Output is correct
58 Correct 32 ms 9036 KB Output is correct
59 Correct 293 ms 26808 KB Output is correct
60 Correct 284 ms 26792 KB Output is correct
61 Correct 294 ms 26808 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 279 ms 26712 KB Output is correct
64 Correct 245 ms 26712 KB Output is correct
65 Correct 280 ms 35624 KB Output is correct
66 Correct 250 ms 35628 KB Output is correct
67 Correct 218 ms 27836 KB Output is correct
68 Correct 237 ms 27904 KB Output is correct
69 Correct 255 ms 31644 KB Output is correct
70 Correct 27 ms 10048 KB Output is correct
71 Correct 28 ms 10068 KB Output is correct
72 Correct 30 ms 10128 KB Output is correct
73 Correct 25 ms 10092 KB Output is correct
74 Correct 31 ms 10120 KB Output is correct
75 Correct 32 ms 10124 KB Output is correct
76 Correct 26 ms 10132 KB Output is correct
77 Correct 35 ms 10136 KB Output is correct
78 Correct 34 ms 10100 KB Output is correct
79 Correct 34 ms 10080 KB Output is correct
80 Correct 31 ms 10108 KB Output is correct
81 Correct 32 ms 10128 KB Output is correct
82 Correct 29 ms 10124 KB Output is correct
83 Correct 28 ms 10060 KB Output is correct
84 Correct 30 ms 10124 KB Output is correct
85 Correct 32 ms 10076 KB Output is correct
86 Correct 34 ms 10024 KB Output is correct
87 Correct 26 ms 10096 KB Output is correct
88 Correct 32 ms 10124 KB Output is correct
89 Correct 35 ms 10132 KB Output is correct
90 Correct 31 ms 10192 KB Output is correct