답안 #66885

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66885 2018-08-12T18:16:25 Z hamzqq9 Dango Maker (JOI18_dango_maker) C++14
100 / 100
838 ms 154684 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 100000000000000
#define MOD 1000000007
#define N 3005
#define MAX 10000006
#define LOG 22
using namespace std;

int n,m,ans;
int dp[N][N][2],node[N][N][2];
char a[N][N];

int main() {
 
	//freopen("input.txt","r",stdin);
 
	scanf("%d %d",&n,&m);

	for(int i=1;i<=n;i++) {

		for(int j=1;j<=m;j++) {

			scanf(" %c",&a[i][j]);

		}

	}

	// 0 vertical 1 horizontal

	for(int i=1;i<=n;i++) {

		if(i>1 && i<n) {

			for(int j=1;j<=m;j++) {

				if(a[i-1][j]=='R' && a[i][j]=='G' && a[i+1][j]=='W') node[i][j][0]=1;

			}

		}

		for(int j=2;j<=m;j++) {

			if(a[i][j-1]=='R' && a[i][j]=='G' && a[i][j+1]=='W') node[i][j][1]=1;

		}

	}

	for(int i=n;i>=1;i--) {

		for(int j=1;j<=m;j++) {

			dp[i][j][0]=max(dp[i+1][j-1][1],dp[i+1][j-1][0]+node[i][j][0]);
			dp[i][j][1]=max(dp[i+1][j-1][0],dp[i+1][j-1][1]+node[i][j][1]);

		}

	}

	for(int i=1;i<=m;i++) ans+=max(dp[1][i][0],dp[1][i][1]);

	for(int i=2;i<=n;i++) ans+=max(dp[i][m][0],dp[i][m][1]);

	printf("%d",ans);

} 	
 

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:32: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:38:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&a[i][j]);
    ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 2 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 2 ms 612 KB Output is correct
17 Correct 2 ms 612 KB Output is correct
18 Correct 2 ms 612 KB Output is correct
19 Correct 2 ms 612 KB Output is correct
20 Correct 2 ms 612 KB Output is correct
21 Correct 3 ms 612 KB Output is correct
22 Correct 3 ms 612 KB Output is correct
23 Correct 2 ms 612 KB Output is correct
24 Correct 2 ms 612 KB Output is correct
25 Correct 2 ms 612 KB Output is correct
26 Correct 2 ms 612 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 2 ms 724 KB Output is correct
29 Correct 2 ms 724 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 724 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
34 Correct 2 ms 724 KB Output is correct
35 Correct 3 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 2 ms 724 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 3 ms 724 KB Output is correct
41 Correct 2 ms 724 KB Output is correct
42 Correct 3 ms 724 KB Output is correct
43 Correct 2 ms 724 KB Output is correct
44 Correct 2 ms 724 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 2 ms 724 KB Output is correct
47 Correct 3 ms 724 KB Output is correct
48 Correct 2 ms 724 KB Output is correct
49 Correct 2 ms 724 KB Output is correct
50 Correct 2 ms 724 KB Output is correct
51 Correct 2 ms 724 KB Output is correct
52 Correct 2 ms 724 KB Output is correct
53 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 3 ms 564 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 2 ms 612 KB Output is correct
17 Correct 2 ms 612 KB Output is correct
18 Correct 2 ms 612 KB Output is correct
19 Correct 2 ms 612 KB Output is correct
20 Correct 2 ms 612 KB Output is correct
21 Correct 3 ms 612 KB Output is correct
22 Correct 3 ms 612 KB Output is correct
23 Correct 2 ms 612 KB Output is correct
24 Correct 2 ms 612 KB Output is correct
25 Correct 2 ms 612 KB Output is correct
26 Correct 2 ms 612 KB Output is correct
27 Correct 2 ms 724 KB Output is correct
28 Correct 2 ms 724 KB Output is correct
29 Correct 2 ms 724 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 724 KB Output is correct
33 Correct 2 ms 724 KB Output is correct
34 Correct 2 ms 724 KB Output is correct
35 Correct 3 ms 724 KB Output is correct
36 Correct 2 ms 724 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
38 Correct 2 ms 724 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 3 ms 724 KB Output is correct
41 Correct 2 ms 724 KB Output is correct
42 Correct 3 ms 724 KB Output is correct
43 Correct 2 ms 724 KB Output is correct
44 Correct 2 ms 724 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 2 ms 724 KB Output is correct
47 Correct 3 ms 724 KB Output is correct
48 Correct 2 ms 724 KB Output is correct
49 Correct 2 ms 724 KB Output is correct
50 Correct 2 ms 724 KB Output is correct
51 Correct 2 ms 724 KB Output is correct
52 Correct 2 ms 724 KB Output is correct
53 Correct 2 ms 724 KB Output is correct
54 Correct 2 ms 724 KB Output is correct
55 Correct 18 ms 22116 KB Output is correct
56 Correct 3 ms 22116 KB Output is correct
57 Correct 17 ms 22116 KB Output is correct
58 Correct 93 ms 27100 KB Output is correct
59 Correct 823 ms 150552 KB Output is correct
60 Correct 818 ms 154332 KB Output is correct
61 Correct 807 ms 154444 KB Output is correct
62 Correct 3 ms 154444 KB Output is correct
63 Correct 838 ms 154556 KB Output is correct
64 Correct 714 ms 154684 KB Output is correct
65 Correct 664 ms 154684 KB Output is correct
66 Correct 724 ms 154684 KB Output is correct
67 Correct 739 ms 154684 KB Output is correct
68 Correct 830 ms 154684 KB Output is correct
69 Correct 622 ms 154684 KB Output is correct
70 Correct 86 ms 154684 KB Output is correct
71 Correct 102 ms 154684 KB Output is correct
72 Correct 77 ms 154684 KB Output is correct
73 Correct 82 ms 154684 KB Output is correct
74 Correct 85 ms 154684 KB Output is correct
75 Correct 84 ms 154684 KB Output is correct
76 Correct 82 ms 154684 KB Output is correct
77 Correct 77 ms 154684 KB Output is correct
78 Correct 82 ms 154684 KB Output is correct
79 Correct 76 ms 154684 KB Output is correct
80 Correct 102 ms 154684 KB Output is correct
81 Correct 86 ms 154684 KB Output is correct
82 Correct 77 ms 154684 KB Output is correct
83 Correct 94 ms 154684 KB Output is correct
84 Correct 101 ms 154684 KB Output is correct
85 Correct 97 ms 154684 KB Output is correct
86 Correct 78 ms 154684 KB Output is correct
87 Correct 87 ms 154684 KB Output is correct
88 Correct 89 ms 154684 KB Output is correct
89 Correct 108 ms 154684 KB Output is correct
90 Correct 88 ms 154684 KB Output is correct