# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
103051 | 2019-03-28T23:43:46 Z | tincamatei | Dango Maker (JOI18_dango_maker) | C++14 | 237 ms | 88704 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 3000; int dp[2][1+MAX_N+1][1+MAX_N+1]; char matr[1+MAX_N+1][1+MAX_N+1]; char getch(FILE *fin) { char ch = fgetc(fin); while(!isalpha(ch)) ch = fgetc(fin); return ch; } int main() { #ifdef HOME FILE *fin = fopen("input.in", "r"); FILE *fout = fopen("output.out", "w"); #else FILE *fin = stdin; FILE *fout = stdout; #endif int n, m; fscanf(fin, "%d%d", &n, &m); for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) matr[i][j] = getch(fin); for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) { dp[0][i][j] = max(dp[0][i - 1][j + 1], dp[1][i - 1][j + 1]); dp[1][i][j] = dp[0][i][j]; if(matr[i][j] == 'G' && matr[i][j - 1] == 'R' && matr[i][j + 1] == 'W') dp[0][i][j] = max(dp[0][i][j], dp[0][i - 1][j + 1] + 1); if(matr[i][j] == 'G' && matr[i - 1][j] == 'R' && matr[i + 1][j] == 'W') dp[1][i][j] = max(dp[1][i][j], dp[1][i - 1][j + 1] + 1); } int rez = 0; for(int i = 1; i <= n; ++i) rez = rez + max(dp[0][i][1], dp[1][i][1]); for(int i = 2; i <= m; ++i) rez = rez + max(dp[0][n][i], dp[1][n][i]); fprintf(fout, "%d", rez); fclose(fin); fclose(fout); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 412 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 412 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 512 KB | Output is correct |
21 | Correct | 2 ms | 512 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 512 KB | Output is correct |
24 | Correct | 3 ms | 512 KB | Output is correct |
25 | Correct | 2 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 512 KB | Output is correct |
29 | Correct | 3 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 512 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 2 ms | 384 KB | Output is correct |
37 | Correct | 2 ms | 512 KB | Output is correct |
38 | Correct | 2 ms | 384 KB | Output is correct |
39 | Correct | 3 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 2 ms | 384 KB | Output is correct |
42 | Correct | 2 ms | 512 KB | Output is correct |
43 | Correct | 3 ms | 428 KB | Output is correct |
44 | Correct | 2 ms | 512 KB | Output is correct |
45 | Correct | 2 ms | 384 KB | Output is correct |
46 | Correct | 2 ms | 384 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 2 ms | 512 KB | Output is correct |
49 | Correct | 2 ms | 512 KB | Output is correct |
50 | Correct | 2 ms | 512 KB | Output is correct |
51 | Correct | 2 ms | 384 KB | Output is correct |
52 | Correct | 0 ms | 384 KB | Output is correct |
53 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 3 ms | 412 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 512 KB | Output is correct |
21 | Correct | 2 ms | 512 KB | Output is correct |
22 | Correct | 2 ms | 512 KB | Output is correct |
23 | Correct | 2 ms | 512 KB | Output is correct |
24 | Correct | 3 ms | 512 KB | Output is correct |
25 | Correct | 2 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 512 KB | Output is correct |
29 | Correct | 3 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 512 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 2 ms | 384 KB | Output is correct |
37 | Correct | 2 ms | 512 KB | Output is correct |
38 | Correct | 2 ms | 384 KB | Output is correct |
39 | Correct | 3 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 2 ms | 384 KB | Output is correct |
42 | Correct | 2 ms | 512 KB | Output is correct |
43 | Correct | 3 ms | 428 KB | Output is correct |
44 | Correct | 2 ms | 512 KB | Output is correct |
45 | Correct | 2 ms | 384 KB | Output is correct |
46 | Correct | 2 ms | 384 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 2 ms | 512 KB | Output is correct |
49 | Correct | 2 ms | 512 KB | Output is correct |
50 | Correct | 2 ms | 512 KB | Output is correct |
51 | Correct | 2 ms | 384 KB | Output is correct |
52 | Correct | 0 ms | 384 KB | Output is correct |
53 | Correct | 2 ms | 384 KB | Output is correct |
54 | Correct | 3 ms | 384 KB | Output is correct |
55 | Correct | 26 ms | 33312 KB | Output is correct |
56 | Correct | 2 ms | 512 KB | Output is correct |
57 | Correct | 18 ms | 22400 KB | Output is correct |
58 | Correct | 37 ms | 20096 KB | Output is correct |
59 | Correct | 216 ms | 88664 KB | Output is correct |
60 | Correct | 222 ms | 88440 KB | Output is correct |
61 | Correct | 218 ms | 88516 KB | Output is correct |
62 | Correct | 2 ms | 384 KB | Output is correct |
63 | Correct | 220 ms | 88244 KB | Output is correct |
64 | Correct | 237 ms | 88704 KB | Output is correct |
65 | Correct | 167 ms | 88468 KB | Output is correct |
66 | Correct | 193 ms | 88568 KB | Output is correct |
67 | Correct | 164 ms | 88468 KB | Output is correct |
68 | Correct | 202 ms | 88412 KB | Output is correct |
69 | Correct | 197 ms | 88456 KB | Output is correct |
70 | Correct | 31 ms | 20216 KB | Output is correct |
71 | Correct | 28 ms | 20096 KB | Output is correct |
72 | Correct | 39 ms | 20060 KB | Output is correct |
73 | Correct | 40 ms | 20088 KB | Output is correct |
74 | Correct | 37 ms | 20088 KB | Output is correct |
75 | Correct | 29 ms | 20048 KB | Output is correct |
76 | Correct | 28 ms | 20092 KB | Output is correct |
77 | Correct | 28 ms | 20088 KB | Output is correct |
78 | Correct | 28 ms | 20088 KB | Output is correct |
79 | Correct | 29 ms | 20060 KB | Output is correct |
80 | Correct | 30 ms | 20088 KB | Output is correct |
81 | Correct | 33 ms | 20088 KB | Output is correct |
82 | Correct | 31 ms | 20160 KB | Output is correct |
83 | Correct | 26 ms | 20088 KB | Output is correct |
84 | Correct | 31 ms | 20092 KB | Output is correct |
85 | Correct | 28 ms | 20088 KB | Output is correct |
86 | Correct | 45 ms | 20088 KB | Output is correct |
87 | Correct | 28 ms | 20088 KB | Output is correct |
88 | Correct | 28 ms | 20088 KB | Output is correct |
89 | Correct | 35 ms | 20088 KB | Output is correct |
90 | Correct | 34 ms | 20216 KB | Output is correct |