답안 #949819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949819 2024-03-19T18:14:53 Z amirhoseinfar1385 Dango Maker (JOI18_dango_maker) C++17
100 / 100
401 ms 199548 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn=3005;
int all[maxn][maxn],n,m,mainres=0,row[maxn][maxn],cal[maxn][maxn];
vector<pair<int,int>>asabnadaram[maxn*2];
struct fdp{
	int r,c;
	fdp(){
		r=c=0;
	}
};

void vorod(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char c;
			cin>>c;
			if(c=='R'){
				all[i][j]=1;
			}else if(c=='G'){
				all[i][j]=2;
			}else{
				all[i][j]=3;
			}
			//cin>>all[i][j];
		}
	}
}

void pre(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(all[i][j]==1&&all[i][j+1]==2&&all[i][j+2]==3){
				row[i][j]=1;
			}
			if(all[i][j]==1&&all[i+1][j]==2&&all[i+2][j]==3){
				cal[i][j]=1;
			}
		}
	}
}
vector<fdp>dp(maxn+6);


void calres(vector<pair<int,int>>&v){
	for(int i=4;i<v.size();i++){
		if(v[i].first==0){
			dp[i].r=max(dp[i-1].r,dp[i-1].c);
		}else{
			dp[i].r=max(dp[i-1].r,dp[i-1].c)+1;
		}
		dp[i].c=max(dp[i-1].c,max(dp[i-2].c,max(dp[i-3].r,dp[i-3].c)));
		if(v[i].second){
			dp[i].c++;
		}
	}
	mainres+=max(dp[(int)v.size()-1].c,dp[(int)v.size()-1].r);
}

void solve(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			asabnadaram[i+j].push_back(make_pair(row[i][j],cal[i][j]));
		}
	}
	for(int i=0;i<maxn*2;i++){
		asabnadaram[i].push_back(make_pair(0,0));
		asabnadaram[i].push_back(make_pair(0,0));
		asabnadaram[i].push_back(make_pair(0,0));
		asabnadaram[i].push_back(make_pair(0,0));
		reverse(asabnadaram[i].begin(),asabnadaram[i].end());
	}
	for(int i=0;i<maxn*2;i++){
		calres(asabnadaram[i]);
	}
}

void khor(){
	cout<<mainres<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen("inp.txt","r",stdin);
	vorod();
	pre();
	solve();
	khor();
}

Compilation message

dango_maker.cpp: In function 'void calres(std::vector<std::pair<int, int> >&)':
dango_maker.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |  for(int i=4;i<v.size();i++){
      |              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 3 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4852 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 2904 KB Output is correct
15 Correct 2 ms 2904 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 3 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4852 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 2904 KB Output is correct
15 Correct 2 ms 2904 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 7000 KB Output is correct
19 Correct 2 ms 7004 KB Output is correct
20 Correct 1 ms 7004 KB Output is correct
21 Correct 2 ms 7004 KB Output is correct
22 Correct 2 ms 7052 KB Output is correct
23 Correct 2 ms 7004 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 1 ms 2904 KB Output is correct
26 Correct 1 ms 2908 KB Output is correct
27 Correct 2 ms 7004 KB Output is correct
28 Correct 2 ms 7004 KB Output is correct
29 Correct 2 ms 7000 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 ms 7004 KB Output is correct
34 Correct 2 ms 7004 KB Output is correct
35 Correct 2 ms 7004 KB Output is correct
36 Correct 2 ms 7004 KB Output is correct
37 Correct 2 ms 7004 KB Output is correct
38 Correct 2 ms 7000 KB Output is correct
39 Correct 2 ms 7004 KB Output is correct
40 Correct 2 ms 7016 KB Output is correct
41 Correct 2 ms 7004 KB Output is correct
42 Correct 2 ms 7004 KB Output is correct
43 Correct 2 ms 7004 KB Output is correct
44 Correct 2 ms 7056 KB Output is correct
45 Correct 2 ms 7004 KB Output is correct
46 Correct 3 ms 7004 KB Output is correct
47 Correct 2 ms 7000 KB Output is correct
48 Correct 2 ms 7004 KB Output is correct
49 Correct 2 ms 7004 KB Output is correct
50 Correct 2 ms 7004 KB Output is correct
51 Correct 2 ms 7004 KB Output is correct
52 Correct 2 ms 7004 KB Output is correct
53 Correct 1 ms 7004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2904 KB Output is correct
2 Correct 1 ms 2908 KB Output is correct
3 Correct 1 ms 2908 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 3 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4852 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 2904 KB Output is correct
15 Correct 2 ms 2904 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 7000 KB Output is correct
19 Correct 2 ms 7004 KB Output is correct
20 Correct 1 ms 7004 KB Output is correct
21 Correct 2 ms 7004 KB Output is correct
22 Correct 2 ms 7052 KB Output is correct
23 Correct 2 ms 7004 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 1 ms 2904 KB Output is correct
26 Correct 1 ms 2908 KB Output is correct
27 Correct 2 ms 7004 KB Output is correct
28 Correct 2 ms 7004 KB Output is correct
29 Correct 2 ms 7000 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 ms 7004 KB Output is correct
34 Correct 2 ms 7004 KB Output is correct
35 Correct 2 ms 7004 KB Output is correct
36 Correct 2 ms 7004 KB Output is correct
37 Correct 2 ms 7004 KB Output is correct
38 Correct 2 ms 7000 KB Output is correct
39 Correct 2 ms 7004 KB Output is correct
40 Correct 2 ms 7016 KB Output is correct
41 Correct 2 ms 7004 KB Output is correct
42 Correct 2 ms 7004 KB Output is correct
43 Correct 2 ms 7004 KB Output is correct
44 Correct 2 ms 7056 KB Output is correct
45 Correct 2 ms 7004 KB Output is correct
46 Correct 3 ms 7004 KB Output is correct
47 Correct 2 ms 7000 KB Output is correct
48 Correct 2 ms 7004 KB Output is correct
49 Correct 2 ms 7004 KB Output is correct
50 Correct 2 ms 7004 KB Output is correct
51 Correct 2 ms 7004 KB Output is correct
52 Correct 2 ms 7004 KB Output is correct
53 Correct 1 ms 7004 KB Output is correct
54 Correct 2 ms 4956 KB Output is correct
55 Correct 10 ms 73304 KB Output is correct
56 Correct 3 ms 7256 KB Output is correct
57 Correct 10 ms 74840 KB Output is correct
58 Correct 47 ms 50256 KB Output is correct
59 Correct 401 ms 199548 KB Output is correct
60 Correct 395 ms 199392 KB Output is correct
61 Correct 397 ms 199252 KB Output is correct
62 Correct 2 ms 5112 KB Output is correct
63 Correct 385 ms 196180 KB Output is correct
64 Correct 265 ms 199248 KB Output is correct
65 Correct 264 ms 199248 KB Output is correct
66 Correct 264 ms 199476 KB Output is correct
67 Correct 257 ms 166524 KB Output is correct
68 Correct 268 ms 193364 KB Output is correct
69 Correct 273 ms 199296 KB Output is correct
70 Correct 38 ms 50264 KB Output is correct
71 Correct 35 ms 50452 KB Output is correct
72 Correct 35 ms 50512 KB Output is correct
73 Correct 33 ms 50384 KB Output is correct
74 Correct 32 ms 50264 KB Output is correct
75 Correct 33 ms 50264 KB Output is correct
76 Correct 33 ms 50256 KB Output is correct
77 Correct 33 ms 50256 KB Output is correct
78 Correct 33 ms 50268 KB Output is correct
79 Correct 41 ms 50256 KB Output is correct
80 Correct 34 ms 50268 KB Output is correct
81 Correct 34 ms 50260 KB Output is correct
82 Correct 33 ms 50256 KB Output is correct
83 Correct 33 ms 50268 KB Output is correct
84 Correct 33 ms 50268 KB Output is correct
85 Correct 32 ms 50260 KB Output is correct
86 Correct 35 ms 50256 KB Output is correct
87 Correct 32 ms 50256 KB Output is correct
88 Correct 33 ms 50316 KB Output is correct
89 Correct 33 ms 50268 KB Output is correct
90 Correct 37 ms 50268 KB Output is correct