답안 #757101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757101 2023-06-12T15:50:07 Z qwertyqwerty Dango Maker (JOI18_dango_maker) C++14
100 / 100
290 ms 159296 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
 
int n, m;
char s[3010][3010];
 
int dp[6010][3010][2];
 
bool is(int i, int j, char c){
	return 1<=i && i<=n && 1<=j && j<=m && s[i][j] == c;
}
 
int main()
{
	read(n, m);
	for(int i=1; i<=n; ++i) scanf("%s", s[i]+1);
	
	int ans = 0;
	for(int s=2; s<=n+m-2; ++s){
		int rm=0;
		for(int i=1; i<=n; ++i){
			dp[s][i][0] = max({dp[s][i][0], dp[s][i-1][0], dp[s][i-2][1]});
			dp[s][i][1] = max({dp[s][i][1], dp[s][i-1][1],dp[s][i-2][0]});
			int j=s-i;
			if(j<1 || j>m) continue;
			if(is(i, j, 'R') && is(i, j+1, 'G') && is(i, j+2, 'W')){
				dp[s][i][0] = max(dp[s][i][0], dp[s][i-1][0]+1);
			}
			if(is(i, j, 'R') && is(i+1, j, 'G') && is(i+2, j, 'W')){
				dp[s][i][1] = max({dp[s][i][1], dp[s][i-1][1]+1, dp[s][i-1][0]+1});
			}
			rm=max({rm, dp[s][i][0], dp[s][i][1]});
		}
		//if(rm) printf("%d: rm %d\n", s, rm);
		ans += rm;
	}
	
	printf("%d\n", ans);
	return 0;
}

Compilation message

dango_maker.cpp: In function 'void read(int&)':
dango_maker.cpp:6:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | void read(int& x){ scanf("%d",&x); }
      |                    ~~~~~^~~~~~~~~
dango_maker.cpp: In function 'void read(ll&)':
dango_maker.cpp:7:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | void read(ll& x){ scanf("%lld",&x); }
      |                   ~~~~~^~~~~~~~~~~
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:28:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  for(int i=1; i<=n; ++i) scanf("%s", s[i]+1);
      |                          ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 308 KB Output is correct
35 Correct 1 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 308 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 308 KB Output is correct
35 Correct 1 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 308 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 308 KB Output is correct
54 Correct 9 ms 12372 KB Output is correct
55 Correct 85 ms 79724 KB Output is correct
56 Correct 8 ms 12476 KB Output is correct
57 Correct 43 ms 45588 KB Output is correct
58 Correct 39 ms 27848 KB Output is correct
59 Correct 271 ms 159200 KB Output is correct
60 Correct 283 ms 159296 KB Output is correct
61 Correct 290 ms 159124 KB Output is correct
62 Correct 7 ms 11732 KB Output is correct
63 Correct 270 ms 156512 KB Output is correct
64 Correct 231 ms 159144 KB Output is correct
65 Correct 239 ms 159200 KB Output is correct
66 Correct 227 ms 159144 KB Output is correct
67 Correct 260 ms 159116 KB Output is correct
68 Correct 227 ms 159136 KB Output is correct
69 Correct 254 ms 159160 KB Output is correct
70 Correct 38 ms 27884 KB Output is correct
71 Correct 33 ms 27960 KB Output is correct
72 Correct 31 ms 27840 KB Output is correct
73 Correct 30 ms 27832 KB Output is correct
74 Correct 29 ms 27884 KB Output is correct
75 Correct 29 ms 27808 KB Output is correct
76 Correct 28 ms 27844 KB Output is correct
77 Correct 32 ms 27984 KB Output is correct
78 Correct 30 ms 27804 KB Output is correct
79 Correct 31 ms 27792 KB Output is correct
80 Correct 37 ms 27792 KB Output is correct
81 Correct 33 ms 27884 KB Output is correct
82 Correct 33 ms 27888 KB Output is correct
83 Correct 28 ms 27852 KB Output is correct
84 Correct 31 ms 27848 KB Output is correct
85 Correct 30 ms 27852 KB Output is correct
86 Correct 32 ms 27832 KB Output is correct
87 Correct 30 ms 27812 KB Output is correct
88 Correct 30 ms 27912 KB Output is correct
89 Correct 30 ms 27868 KB Output is correct
90 Correct 32 ms 27860 KB Output is correct