답안 #41262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41262 2018-02-15T09:14:47 Z Kerim Dango Maker (JOI18_dango_maker) C++14
100 / 100
933 ms 121388 KB
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=3e3+6;
int mask[N][N],dp[N][3],n,m;
char arr[N][N];
int rec(int xx,int yy,int pos,int last){
	int x=xx+pos,y=yy-pos;
	if(x<0 or y<0 or x>=n or y>=m)
		return 0;
	int &ret=dp[pos][last];
	if(~ret)
		return ret;ret=rec(xx,yy,pos+1,0);
	if(!mask[x][y])
		return ret;
	else if(mask[x][y]==1){
		if(last!=2)
			umax(ret,rec(xx,yy,pos+1,1)+1);
		return ret;
	}	
	else if(mask[x][y]==2){
		if(last!=1)
			umax(ret,rec(xx,yy,pos+1,2)+1);
		return ret;
	}
	if(last!=1)
		umax(ret,rec(xx,yy,pos+1,2)+1);
	if(last!=2)
		umax(ret,rec(xx,yy,pos+1,1)+1);
	return ret;		
}
int main(){
    //~ freopen("file.in", "r", stdin);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			scanf(" %c",&arr[i][j]);
	for(int i=0;i<n;i++)	
		for(int j=0;j<m;j++)
			if(arr[i][j]=='G'){
				if(j>0 and j+1<m and arr[i][j-1]=='R' and arr[i][j+1]=='W')
					mask[i][j]|=1;
				if(i>0 and i+1<n and arr[i-1][j]=='R' and arr[i+1][j]=='W')
					mask[i][j]|=2;
			}
	int ans=0;	
	for(int i=0;i<m;i++){
		memset(dp,-1,sizeof dp);
		ans+=rec(0,i,0,0);
	}
	for(int i=1;i<n;i++){
		memset(dp,-1,sizeof dp);
		ans+=rec(i,m-1,0,0);
	}
	printf("%d\n",ans);	
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:50:24: 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:53:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %c",&arr[i][j]);
                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 632 KB Output is correct
9 Correct 1 ms 636 KB Output is correct
10 Correct 2 ms 656 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 2 ms 664 KB Output is correct
13 Correct 2 ms 672 KB Output is correct
14 Correct 1 ms 676 KB Output is correct
15 Correct 1 ms 676 KB Output is correct
16 Correct 1 ms 676 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 1 ms 432 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 632 KB Output is correct
9 Correct 1 ms 636 KB Output is correct
10 Correct 2 ms 656 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 2 ms 664 KB Output is correct
13 Correct 2 ms 672 KB Output is correct
14 Correct 1 ms 676 KB Output is correct
15 Correct 1 ms 676 KB Output is correct
16 Correct 1 ms 676 KB Output is correct
17 Correct 2 ms 684 KB Output is correct
18 Correct 1 ms 688 KB Output is correct
19 Correct 1 ms 692 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 828 KB Output is correct
22 Correct 2 ms 828 KB Output is correct
23 Correct 2 ms 828 KB Output is correct
24 Correct 2 ms 828 KB Output is correct
25 Correct 1 ms 828 KB Output is correct
26 Correct 1 ms 828 KB Output is correct
27 Correct 2 ms 828 KB Output is correct
28 Correct 2 ms 828 KB Output is correct
29 Correct 2 ms 828 KB Output is correct
30 Correct 1 ms 828 KB Output is correct
31 Correct 1 ms 828 KB Output is correct
32 Correct 2 ms 828 KB Output is correct
33 Correct 2 ms 828 KB Output is correct
34 Correct 2 ms 828 KB Output is correct
35 Correct 1 ms 828 KB Output is correct
36 Correct 2 ms 828 KB Output is correct
37 Correct 2 ms 828 KB Output is correct
38 Correct 2 ms 828 KB Output is correct
39 Correct 1 ms 828 KB Output is correct
40 Correct 2 ms 828 KB Output is correct
41 Correct 1 ms 828 KB Output is correct
42 Correct 2 ms 828 KB Output is correct
43 Correct 1 ms 828 KB Output is correct
44 Correct 2 ms 828 KB Output is correct
45 Correct 2 ms 828 KB Output is correct
46 Correct 1 ms 828 KB Output is correct
47 Correct 2 ms 828 KB Output is correct
48 Correct 2 ms 828 KB Output is correct
49 Correct 2 ms 828 KB Output is correct
50 Correct 2 ms 828 KB Output is correct
51 Correct 2 ms 828 KB Output is correct
52 Correct 2 ms 828 KB Output is correct
53 Correct 2 ms 852 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 1 ms 432 KB Output is correct
4 Correct 1 ms 508 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 632 KB Output is correct
9 Correct 1 ms 636 KB Output is correct
10 Correct 2 ms 656 KB Output is correct
11 Correct 2 ms 660 KB Output is correct
12 Correct 2 ms 664 KB Output is correct
13 Correct 2 ms 672 KB Output is correct
14 Correct 1 ms 676 KB Output is correct
15 Correct 1 ms 676 KB Output is correct
16 Correct 1 ms 676 KB Output is correct
17 Correct 2 ms 684 KB Output is correct
18 Correct 1 ms 688 KB Output is correct
19 Correct 1 ms 692 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 828 KB Output is correct
22 Correct 2 ms 828 KB Output is correct
23 Correct 2 ms 828 KB Output is correct
24 Correct 2 ms 828 KB Output is correct
25 Correct 1 ms 828 KB Output is correct
26 Correct 1 ms 828 KB Output is correct
27 Correct 2 ms 828 KB Output is correct
28 Correct 2 ms 828 KB Output is correct
29 Correct 2 ms 828 KB Output is correct
30 Correct 1 ms 828 KB Output is correct
31 Correct 1 ms 828 KB Output is correct
32 Correct 2 ms 828 KB Output is correct
33 Correct 2 ms 828 KB Output is correct
34 Correct 2 ms 828 KB Output is correct
35 Correct 1 ms 828 KB Output is correct
36 Correct 2 ms 828 KB Output is correct
37 Correct 2 ms 828 KB Output is correct
38 Correct 2 ms 828 KB Output is correct
39 Correct 1 ms 828 KB Output is correct
40 Correct 2 ms 828 KB Output is correct
41 Correct 1 ms 828 KB Output is correct
42 Correct 2 ms 828 KB Output is correct
43 Correct 1 ms 828 KB Output is correct
44 Correct 2 ms 828 KB Output is correct
45 Correct 2 ms 828 KB Output is correct
46 Correct 1 ms 828 KB Output is correct
47 Correct 2 ms 828 KB Output is correct
48 Correct 2 ms 828 KB Output is correct
49 Correct 2 ms 828 KB Output is correct
50 Correct 2 ms 828 KB Output is correct
51 Correct 2 ms 828 KB Output is correct
52 Correct 2 ms 828 KB Output is correct
53 Correct 2 ms 852 KB Output is correct
54 Correct 6 ms 852 KB Output is correct
55 Correct 16 ms 10056 KB Output is correct
56 Correct 7 ms 10056 KB Output is correct
57 Correct 15 ms 13968 KB Output is correct
58 Correct 92 ms 13968 KB Output is correct
59 Correct 875 ms 55148 KB Output is correct
60 Correct 803 ms 63976 KB Output is correct
61 Correct 804 ms 72944 KB Output is correct
62 Correct 6 ms 72944 KB Output is correct
63 Correct 828 ms 81496 KB Output is correct
64 Correct 933 ms 90288 KB Output is correct
65 Correct 896 ms 98972 KB Output is correct
66 Correct 885 ms 107892 KB Output is correct
67 Correct 736 ms 107892 KB Output is correct
68 Correct 841 ms 107892 KB Output is correct
69 Correct 884 ms 120412 KB Output is correct
70 Correct 105 ms 120412 KB Output is correct
71 Correct 101 ms 120412 KB Output is correct
72 Correct 99 ms 120412 KB Output is correct
73 Correct 106 ms 120412 KB Output is correct
74 Correct 99 ms 120412 KB Output is correct
75 Correct 96 ms 120412 KB Output is correct
76 Correct 107 ms 120412 KB Output is correct
77 Correct 100 ms 120412 KB Output is correct
78 Correct 111 ms 120412 KB Output is correct
79 Correct 109 ms 120412 KB Output is correct
80 Correct 97 ms 120412 KB Output is correct
81 Correct 105 ms 120412 KB Output is correct
82 Correct 116 ms 120412 KB Output is correct
83 Correct 97 ms 120412 KB Output is correct
84 Correct 98 ms 120412 KB Output is correct
85 Correct 97 ms 120412 KB Output is correct
86 Correct 96 ms 120412 KB Output is correct
87 Correct 102 ms 120412 KB Output is correct
88 Correct 99 ms 120412 KB Output is correct
89 Correct 98 ms 120484 KB Output is correct
90 Correct 98 ms 121388 KB Output is correct