답안 #99508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99508 2019-03-04T12:16:34 Z psmao Dango Maker (JOI18_dango_maker) C++14
100 / 100
242 ms 27384 KB
#include <bits/stdc++.h>
using namespace std;

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 3050;

int n, m, f[maxn][3];
char a[maxn][maxn];
bool ok[maxn][maxn][2];

int main()
{
	#ifdef MPS	
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	sf("%d%d",&n,&m);
	fo(i,1,n) sf("%s",a[i]+1);
	fo(i,1,n) fo(j,1,m) if(a[i][j] == 'G')
	{
		if(a[i][j-1] == 'R' && a[i][j+1] == 'W') ok[i][j][0] = true;
		if(a[i-1][j] == 'R' && a[i+1][j] == 'W') ok[i][j][1] = true;
	}
	int ans = 0;
	fo(i,2,n+m) // diagonal
	{
		fo(j,1,min(n,i)) fo(k,0,2) f[j][k] = 0;
		int last = 0;
		for(int x = 1, y = i - 1; x <= n; ++ x, -- y)
		{
			if(y < 1 || y > m) continue; // out of the grid
			f[x][0] = max(max(f[x-1][0], f[x-1][1]), f[x-1][2]);
			if(ok[x][y][0]) // we have a horizontal one here
				f[x][1] = max(f[x-1][0], f[x-1][1]) + 1;
			if(ok[x][y][1])
				f[x][2] = max(f[x-1][0], f[x-1][2]) + 1;
			last = x;
		}
		ans += max(f[last][0], max(f[last][1], f[last][2]));
	}
	pf("%d\n",ans);
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:45:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d%d",&n,&m);
    ^
dango_maker.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fo(i,1,n) sf("%s",a[i]+1);
              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 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 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 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 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 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 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 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 2 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 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 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 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 2 ms 384 KB Output is correct
55 Correct 23 ms 9784 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
57 Correct 18 ms 13312 KB Output is correct
58 Correct 30 ms 9216 KB Output is correct
59 Correct 208 ms 27228 KB Output is correct
60 Correct 242 ms 27256 KB Output is correct
61 Correct 223 ms 27256 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 219 ms 27248 KB Output is correct
64 Correct 192 ms 27256 KB Output is correct
65 Correct 239 ms 27260 KB Output is correct
66 Correct 185 ms 27384 KB Output is correct
67 Correct 146 ms 19380 KB Output is correct
68 Correct 197 ms 19280 KB Output is correct
69 Correct 180 ms 23204 KB Output is correct
70 Correct 28 ms 9344 KB Output is correct
71 Correct 23 ms 9344 KB Output is correct
72 Correct 25 ms 9216 KB Output is correct
73 Correct 26 ms 9336 KB Output is correct
74 Correct 33 ms 9336 KB Output is correct
75 Correct 22 ms 9336 KB Output is correct
76 Correct 24 ms 9344 KB Output is correct
77 Correct 27 ms 9344 KB Output is correct
78 Correct 24 ms 9344 KB Output is correct
79 Correct 25 ms 9344 KB Output is correct
80 Correct 24 ms 9216 KB Output is correct
81 Correct 25 ms 9248 KB Output is correct
82 Correct 24 ms 9216 KB Output is correct
83 Correct 25 ms 9336 KB Output is correct
84 Correct 23 ms 9336 KB Output is correct
85 Correct 26 ms 9344 KB Output is correct
86 Correct 25 ms 9344 KB Output is correct
87 Correct 27 ms 9344 KB Output is correct
88 Correct 24 ms 9216 KB Output is correct
89 Correct 23 ms 9344 KB Output is correct
90 Correct 26 ms 9216 KB Output is correct