Submission #634417

# Submission time Handle Problem Language Result Execution time Memory
634417 2022-08-24T11:10:10 Z nguyentu Dango Maker (JOI18_dango_maker) C++14
100 / 100
311 ms 18144 KB
#include <bits/stdc++.h>

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define ii pair<int , int>  
#define iv pair<ii , ii>
#define iii pair<int , ii>
#define fi first
#define se second
#define int long long
const int inf = 1e18 + 7;
const int MAX_N = 3e3 + 7;
const int MOD = 1e9 + 7;

// f[i][0] : khong co thang cuoi cung
// f[i][1] : thang cuoi cung duoc su dung la nam hang ngang
// f[i][2] : thang cuoi cung duoc su dung la nam` hang cot
int f[MAX_N][3];
char a[MAX_N][MAX_N];
int n , m;

bool c(int x , int y , char d) {
    return (0 <= x && x < n && 0 <= y && y < m && a[x][y] == d);
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < m ; j++) {
            cin >> a[i][j];
            //cout << a[i][j] << " ";
        }
    }
    int ans = 0;
    for(int i=0; i<=n+m-4; ++i) {
		int jm=min(m, i+2);
		for(int j=0; j<jm; ++j) {
			f[j+1][0]=max(f[j][0], max(f[j][1], f[j][2]));
			f[j+1][1]=c(i+1-j, j-1, 'R')&&c(i+1-j, j, 'G')&&c(i+1-j, j+1, 'W')?max(f[j][0], f[j][1])+1:0;
			f[j+1][2]=c(i-j, j, 'R')&&c(i+1-j, j, 'G')&&c(i+2-j, j, 'W')?max(f[j][0], f[j][2])+1:0;
		}
		ans+=max(f[jm][0], max(f[jm][1], f[jm][2]));
	}
    cout << ans;
    return 0;
}   
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 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 328 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 324 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 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 1 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 328 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 0 ms 328 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 1 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 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 328 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 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 328 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 0 ms 324 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 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 1 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 328 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 0 ms 328 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 1 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 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 24 ms 340 KB Output is correct
55 Correct 4 ms 9044 KB Output is correct
56 Correct 29 ms 412 KB Output is correct
57 Correct 4 ms 6228 KB Output is correct
58 Correct 33 ms 4200 KB Output is correct
59 Correct 294 ms 18024 KB Output is correct
60 Correct 287 ms 17952 KB Output is correct
61 Correct 311 ms 18020 KB Output is correct
62 Correct 22 ms 400 KB Output is correct
63 Correct 274 ms 17664 KB Output is correct
64 Correct 232 ms 18020 KB Output is correct
65 Correct 277 ms 17996 KB Output is correct
66 Correct 218 ms 18144 KB Output is correct
67 Correct 253 ms 17960 KB Output is correct
68 Correct 221 ms 17976 KB Output is correct
69 Correct 263 ms 17936 KB Output is correct
70 Correct 24 ms 4236 KB Output is correct
71 Correct 24 ms 4172 KB Output is correct
72 Correct 24 ms 4212 KB Output is correct
73 Correct 24 ms 4208 KB Output is correct
74 Correct 32 ms 4172 KB Output is correct
75 Correct 30 ms 4208 KB Output is correct
76 Correct 27 ms 4208 KB Output is correct
77 Correct 24 ms 4204 KB Output is correct
78 Correct 24 ms 4300 KB Output is correct
79 Correct 23 ms 4192 KB Output is correct
80 Correct 24 ms 4164 KB Output is correct
81 Correct 25 ms 4260 KB Output is correct
82 Correct 23 ms 4184 KB Output is correct
83 Correct 31 ms 4204 KB Output is correct
84 Correct 27 ms 4184 KB Output is correct
85 Correct 31 ms 4192 KB Output is correct
86 Correct 24 ms 4308 KB Output is correct
87 Correct 23 ms 4180 KB Output is correct
88 Correct 24 ms 4260 KB Output is correct
89 Correct 25 ms 4220 KB Output is correct
90 Correct 25 ms 4244 KB Output is correct