답안 #125622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125622 2019-07-06T05:33:37 Z gs14004 Dango Maker (JOI18_dango_maker) C++17
100 / 100
244 ms 18168 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
const int MAXN = 3005;

int n, m;
char str[MAXN][MAXN];

int R[MAXN], W[MAXN];
int dR[MAXN], dW[MAXN];

int solve(int n){
	for(int i=1; i<=n; i++){
		dR[i] = dR[i-1];
		dW[i] = dW[i-1];
		if(i > 1){
			dR[i] = max(dR[i], dW[i-2]);
			dW[i] = max(dW[i], dR[i-2]);
		}
		if(R[i-1] && W[i]) dR[i]++;
		if(W[i-1] && R[i]) dW[i]++;
	}
	return max(dR[n], dW[n]);
}
bool okR(int x, int y){ return x >= 0 && x < n && y >= 0 && y < m && str[x][y] == 'R'; }
bool okW(int x, int y){ return x >= 0 && x < n && y >= 0 && y < m && str[x][y] == 'W'; }
bool okG(int x, int y){ return x >= 0 && x < n && y >= 0 && y < m && str[x][y] == 'G'; }

int main(){
	scanf("%d %d",&n,&m);
	for(int i=0; i<n; i++) scanf("%s", str[i]);
	int ans = 0;
	for(int i=0; i<n+m-1; i++){
		vector<pi> v;
		for(int j=0; j<=i; j++){
			if(okG(j, i-j)) v.push_back(pi(j, i-j));
		}
		for(int i=0; i<v.size(); ){
			int e = i;
			while(e < v.size() && v[e].first - v[i].first == e - i) e++;
			R[0] = okR(v[i].first - 1, v[i].second);
			W[0] = okW(v[i].first, v[i].second + 1);
			for(int j=i; j<e; j++){
				R[j-i+1] = okR(v[j].first, v[j].second-1);
				W[j-i+1] = okW(v[j].first + 1, v[j].second);
			}
			ans += solve(e - i);
			i = e;
		}
	}
	cout << ans << endl;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:38:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<v.size(); ){
                ~^~~~~~~~~
dango_maker.cpp:40:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(e < v.size() && v[e].first - v[i].first == e - i) e++;
          ~~^~~~~~~~~~
dango_maker.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
dango_maker.cpp:31:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; i++) scanf("%s", str[i]);
                         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 312 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 312 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 380 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 312 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 380 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 380 KB Output is correct
54 Correct 6 ms 376 KB Output is correct
55 Correct 13 ms 9208 KB Output is correct
56 Correct 7 ms 380 KB Output is correct
57 Correct 9 ms 6236 KB Output is correct
58 Correct 29 ms 4216 KB Output is correct
59 Correct 235 ms 17944 KB Output is correct
60 Correct 233 ms 18168 KB Output is correct
61 Correct 238 ms 18048 KB Output is correct
62 Correct 6 ms 376 KB Output is correct
63 Correct 244 ms 17784 KB Output is correct
64 Correct 172 ms 18040 KB Output is correct
65 Correct 182 ms 18072 KB Output is correct
66 Correct 164 ms 18040 KB Output is correct
67 Correct 174 ms 18012 KB Output is correct
68 Correct 174 ms 18048 KB Output is correct
69 Correct 180 ms 17916 KB Output is correct
70 Correct 19 ms 4248 KB Output is correct
71 Correct 19 ms 4216 KB Output is correct
72 Correct 19 ms 4216 KB Output is correct
73 Correct 19 ms 4344 KB Output is correct
74 Correct 19 ms 4344 KB Output is correct
75 Correct 19 ms 4344 KB Output is correct
76 Correct 19 ms 4344 KB Output is correct
77 Correct 19 ms 4372 KB Output is correct
78 Correct 18 ms 4216 KB Output is correct
79 Correct 18 ms 4216 KB Output is correct
80 Correct 18 ms 4216 KB Output is correct
81 Correct 18 ms 4216 KB Output is correct
82 Correct 19 ms 4388 KB Output is correct
83 Correct 19 ms 4216 KB Output is correct
84 Correct 19 ms 4328 KB Output is correct
85 Correct 18 ms 4216 KB Output is correct
86 Correct 19 ms 4344 KB Output is correct
87 Correct 19 ms 4364 KB Output is correct
88 Correct 19 ms 4216 KB Output is correct
89 Correct 19 ms 4344 KB Output is correct
90 Correct 19 ms 4344 KB Output is correct