Submission #891935

# Submission time Handle Problem Language Result Execution time Memory
891935 2023-12-24T13:23:06 Z goodspeed0208 Dango Maker (JOI18_dango_maker) C++14
100 / 100
357 ms 18252 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<utility>
#define int long long
#define INF 1000000000000000000
#define pii pair<long long, long long>
using namespace std;

int n, m;
char v[3005][3005];
/*
    r c
0 : - -
1 : + -
2 : - +
3 : + +
*/
int ans = 0;
int cmp(int i, int j) {
	if (i < 0 || i >= n || j < 0 || j >= m || v[i][j] != 'G') return -1;
	int row = 0, column = 0;
	if (i > 0 && i < n-1 && v[i-1][j] == 'R' && v[i+1][j] == 'W') column++;
	if (j > 0 && j < m-1 && v[i][j-1] == 'R' && v[i][j+1] == 'W') row++;
	if (column && row) {
		v[i][j] = '/';
		ans++;
		return 3;
	}
	if (row) {
		v[i][j] = v[i][j-1] = v[i][j+1] = '/';
		ans++;
		return 1;
	}
	if (column) {
		v[i][j] = v[i-1][j] = v[i+1][j] = '/';
		ans++;
		return 2;
	}
	return 0;
}

signed main() {
	cin >> n >> m;
	for (int i = 0 ; i < n ; i++) {
		for (int j = 0 ; j < m ; j++) cin >> v[i][j];
	}
	for (int i = 0 ; i < n ; i++) {
		for (int j = 0 ; j < m ; j++) {
			//cout << cmp(i, j) <<" ";
			int ti = i, tj = j;
			while (cmp(ti, tj) == 3) {
				//v[ti][tj] = '/';
				ti++, tj--;
			}
			//v[ti][tj] = '/';
		}
		//cout << "\n";
	}
	cout << ans << "\n";
}

/*
7 6
WWWWRW
WWWRGW
WWRGWR
WWGWWG
RGWWWW
GWWWWW
WWWWWW
*/






# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 440 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 444 KB Output is correct
22 Correct 0 ms 856 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 444 KB Output is correct
35 Correct 0 ms 440 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 444 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 436 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 440 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 444 KB Output is correct
22 Correct 0 ms 856 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 444 KB Output is correct
35 Correct 0 ms 440 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 444 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 436 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 2 ms 9308 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 6748 KB Output is correct
58 Correct 42 ms 5460 KB Output is correct
59 Correct 357 ms 18036 KB Output is correct
60 Correct 355 ms 18252 KB Output is correct
61 Correct 355 ms 18000 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 344 ms 17828 KB Output is correct
64 Correct 310 ms 18000 KB Output is correct
65 Correct 315 ms 18140 KB Output is correct
66 Correct 319 ms 18000 KB Output is correct
67 Correct 317 ms 18136 KB Output is correct
68 Correct 310 ms 18000 KB Output is correct
69 Correct 317 ms 17876 KB Output is correct
70 Correct 35 ms 5456 KB Output is correct
71 Correct 36 ms 5460 KB Output is correct
72 Correct 35 ms 5456 KB Output is correct
73 Correct 35 ms 5456 KB Output is correct
74 Correct 36 ms 5596 KB Output is correct
75 Correct 36 ms 5460 KB Output is correct
76 Correct 36 ms 5464 KB Output is correct
77 Correct 36 ms 5460 KB Output is correct
78 Correct 36 ms 5468 KB Output is correct
79 Correct 36 ms 5468 KB Output is correct
80 Correct 36 ms 5460 KB Output is correct
81 Correct 36 ms 5688 KB Output is correct
82 Correct 36 ms 5468 KB Output is correct
83 Correct 36 ms 5456 KB Output is correct
84 Correct 38 ms 5724 KB Output is correct
85 Correct 36 ms 5456 KB Output is correct
86 Correct 36 ms 5588 KB Output is correct
87 Correct 36 ms 5684 KB Output is correct
88 Correct 37 ms 5468 KB Output is correct
89 Correct 37 ms 5468 KB Output is correct
90 Correct 36 ms 5472 KB Output is correct