답안 #96390

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96390 2019-02-09T08:33:22 Z hugo_pm Dango Maker (JOI18_dango_maker) C++14
100 / 100
944 ms 248176 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= b; --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)

#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second

const long long BIG = 1000000000000000000LL;

typedef long long ll;
typedef long double ld;

void cpr(string s, vector<int> v)
{ int i = 0; for (char c : s) { if (c == '$') cout << v[i++]; else cout << c; } cout << '\n'; }

void cpr(string s) { cpr(s, {}); }

void solve();
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

const int borne = 3005;
int nblig, nbcol;
char grille[borne][borne];
bool rdy[2][borne][borne];
int dp[borne][borne][3];

void tt(int lig, int col)
{
	if (lig > 0 && lig+1 < nblig) {
		if (grille[lig-1][col] == 'R' && grille[lig][col] == 'G' && grille[lig+1][col] == 'W') {
			rdy[0][lig][col] = true;
		}
	}
	if (col > 0 && col+1 < nbcol) {
		if (grille[lig][col-1] == 'R' && grille[lig][col] == 'G' && grille[lig][col+1] == 'W') {
			rdy[1][lig][col] = true;
		}
	}
}

int gdp(int lig, int col, int mode)
{
	int &rep = dp[lig][col][mode];
	if (rep != -1) return rep;
	rep = 0;
	if (lig >= nblig || col < 0) return rep;
	if (mode == 0 || mode == 2) {
		if (rdy[0][lig][col]) {
			chmax(rep, 1+gdp(lig+1,col-1,0));
		}
	}
	if (mode == 1 || mode == 2) {
		if (rdy[1][lig][col]) {
			chmax(rep, 1+gdp(lig+1,col-1,1));
		}
	}
	chmax(rep, gdp(lig+1,col-1,2));
	return rep;
}

void solve()
{
	fill_n(&dp[0][0][0], borne*borne*3, -1);
	cin >> nblig >> nbcol;
	form(i, nblig) form(j, nbcol) {
		cin >> grille[i][j];
	}
	form(i, nblig) form(j, nbcol) {
		tt(i,j);
	}
	int tot = 0;
	tot += gdp(0, nbcol-1, 2);
	form(colini, nbcol-1) tot += gdp(0, colini, 2);
	form2(ligini, 1, nblig) tot += gdp(ligini, nbcol-1, 2);
	cout << tot << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 212676 KB Output is correct
2 Correct 150 ms 212468 KB Output is correct
3 Correct 142 ms 212344 KB Output is correct
4 Correct 146 ms 212468 KB Output is correct
5 Correct 136 ms 212432 KB Output is correct
6 Correct 145 ms 212432 KB Output is correct
7 Correct 139 ms 212368 KB Output is correct
8 Correct 142 ms 212472 KB Output is correct
9 Correct 158 ms 212380 KB Output is correct
10 Correct 157 ms 212448 KB Output is correct
11 Correct 161 ms 212472 KB Output is correct
12 Correct 173 ms 212360 KB Output is correct
13 Correct 172 ms 212412 KB Output is correct
14 Correct 157 ms 212472 KB Output is correct
15 Correct 157 ms 212472 KB Output is correct
16 Correct 163 ms 212404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 212676 KB Output is correct
2 Correct 150 ms 212468 KB Output is correct
3 Correct 142 ms 212344 KB Output is correct
4 Correct 146 ms 212468 KB Output is correct
5 Correct 136 ms 212432 KB Output is correct
6 Correct 145 ms 212432 KB Output is correct
7 Correct 139 ms 212368 KB Output is correct
8 Correct 142 ms 212472 KB Output is correct
9 Correct 158 ms 212380 KB Output is correct
10 Correct 157 ms 212448 KB Output is correct
11 Correct 161 ms 212472 KB Output is correct
12 Correct 173 ms 212360 KB Output is correct
13 Correct 172 ms 212412 KB Output is correct
14 Correct 157 ms 212472 KB Output is correct
15 Correct 157 ms 212472 KB Output is correct
16 Correct 163 ms 212404 KB Output is correct
17 Correct 158 ms 212472 KB Output is correct
18 Correct 158 ms 212472 KB Output is correct
19 Correct 138 ms 212472 KB Output is correct
20 Correct 145 ms 212468 KB Output is correct
21 Correct 138 ms 212472 KB Output is correct
22 Correct 144 ms 212472 KB Output is correct
23 Correct 160 ms 212476 KB Output is correct
24 Correct 146 ms 212412 KB Output is correct
25 Correct 148 ms 212416 KB Output is correct
26 Correct 139 ms 212472 KB Output is correct
27 Correct 139 ms 212504 KB Output is correct
28 Correct 148 ms 212428 KB Output is correct
29 Correct 144 ms 212444 KB Output is correct
30 Correct 137 ms 212472 KB Output is correct
31 Correct 142 ms 212392 KB Output is correct
32 Correct 155 ms 212452 KB Output is correct
33 Correct 143 ms 212472 KB Output is correct
34 Correct 144 ms 212472 KB Output is correct
35 Correct 141 ms 212484 KB Output is correct
36 Correct 145 ms 212460 KB Output is correct
37 Correct 140 ms 212648 KB Output is correct
38 Correct 151 ms 212532 KB Output is correct
39 Correct 144 ms 212624 KB Output is correct
40 Correct 186 ms 212508 KB Output is correct
41 Correct 152 ms 212600 KB Output is correct
42 Correct 192 ms 212456 KB Output is correct
43 Correct 159 ms 212472 KB Output is correct
44 Correct 177 ms 212536 KB Output is correct
45 Correct 158 ms 212552 KB Output is correct
46 Correct 159 ms 212576 KB Output is correct
47 Correct 166 ms 212472 KB Output is correct
48 Correct 163 ms 212472 KB Output is correct
49 Correct 143 ms 212472 KB Output is correct
50 Correct 150 ms 212548 KB Output is correct
51 Correct 147 ms 212532 KB Output is correct
52 Correct 153 ms 212472 KB Output is correct
53 Correct 159 ms 212528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 212676 KB Output is correct
2 Correct 150 ms 212468 KB Output is correct
3 Correct 142 ms 212344 KB Output is correct
4 Correct 146 ms 212468 KB Output is correct
5 Correct 136 ms 212432 KB Output is correct
6 Correct 145 ms 212432 KB Output is correct
7 Correct 139 ms 212368 KB Output is correct
8 Correct 142 ms 212472 KB Output is correct
9 Correct 158 ms 212380 KB Output is correct
10 Correct 157 ms 212448 KB Output is correct
11 Correct 161 ms 212472 KB Output is correct
12 Correct 173 ms 212360 KB Output is correct
13 Correct 172 ms 212412 KB Output is correct
14 Correct 157 ms 212472 KB Output is correct
15 Correct 157 ms 212472 KB Output is correct
16 Correct 163 ms 212404 KB Output is correct
17 Correct 158 ms 212472 KB Output is correct
18 Correct 158 ms 212472 KB Output is correct
19 Correct 138 ms 212472 KB Output is correct
20 Correct 145 ms 212468 KB Output is correct
21 Correct 138 ms 212472 KB Output is correct
22 Correct 144 ms 212472 KB Output is correct
23 Correct 160 ms 212476 KB Output is correct
24 Correct 146 ms 212412 KB Output is correct
25 Correct 148 ms 212416 KB Output is correct
26 Correct 139 ms 212472 KB Output is correct
27 Correct 139 ms 212504 KB Output is correct
28 Correct 148 ms 212428 KB Output is correct
29 Correct 144 ms 212444 KB Output is correct
30 Correct 137 ms 212472 KB Output is correct
31 Correct 142 ms 212392 KB Output is correct
32 Correct 155 ms 212452 KB Output is correct
33 Correct 143 ms 212472 KB Output is correct
34 Correct 144 ms 212472 KB Output is correct
35 Correct 141 ms 212484 KB Output is correct
36 Correct 145 ms 212460 KB Output is correct
37 Correct 140 ms 212648 KB Output is correct
38 Correct 151 ms 212532 KB Output is correct
39 Correct 144 ms 212624 KB Output is correct
40 Correct 186 ms 212508 KB Output is correct
41 Correct 152 ms 212600 KB Output is correct
42 Correct 192 ms 212456 KB Output is correct
43 Correct 159 ms 212472 KB Output is correct
44 Correct 177 ms 212536 KB Output is correct
45 Correct 158 ms 212552 KB Output is correct
46 Correct 159 ms 212576 KB Output is correct
47 Correct 166 ms 212472 KB Output is correct
48 Correct 163 ms 212472 KB Output is correct
49 Correct 143 ms 212472 KB Output is correct
50 Correct 150 ms 212548 KB Output is correct
51 Correct 147 ms 212532 KB Output is correct
52 Correct 153 ms 212472 KB Output is correct
53 Correct 159 ms 212528 KB Output is correct
54 Correct 160 ms 212508 KB Output is correct
55 Correct 172 ms 221660 KB Output is correct
56 Correct 168 ms 212480 KB Output is correct
57 Correct 170 ms 226552 KB Output is correct
58 Correct 235 ms 222444 KB Output is correct
59 Correct 876 ms 248176 KB Output is correct
60 Correct 873 ms 247908 KB Output is correct
61 Correct 917 ms 248040 KB Output is correct
62 Correct 150 ms 212532 KB Output is correct
63 Correct 837 ms 247796 KB Output is correct
64 Correct 944 ms 247968 KB Output is correct
65 Correct 900 ms 247976 KB Output is correct
66 Correct 882 ms 247928 KB Output is correct
67 Correct 713 ms 237304 KB Output is correct
68 Correct 736 ms 237348 KB Output is correct
69 Correct 820 ms 243888 KB Output is correct
70 Correct 255 ms 222456 KB Output is correct
71 Correct 201 ms 222200 KB Output is correct
72 Correct 215 ms 222276 KB Output is correct
73 Correct 203 ms 222328 KB Output is correct
74 Correct 209 ms 222244 KB Output is correct
75 Correct 208 ms 222236 KB Output is correct
76 Correct 232 ms 222324 KB Output is correct
77 Correct 205 ms 222328 KB Output is correct
78 Correct 210 ms 222360 KB Output is correct
79 Correct 212 ms 222328 KB Output is correct
80 Correct 214 ms 222408 KB Output is correct
81 Correct 202 ms 222328 KB Output is correct
82 Correct 211 ms 222460 KB Output is correct
83 Correct 215 ms 222308 KB Output is correct
84 Correct 219 ms 222328 KB Output is correct
85 Correct 237 ms 222328 KB Output is correct
86 Correct 243 ms 222456 KB Output is correct
87 Correct 242 ms 222328 KB Output is correct
88 Correct 242 ms 222300 KB Output is correct
89 Correct 225 ms 222360 KB Output is correct
90 Correct 228 ms 222448 KB Output is correct