답안 #709716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
709716 2023-03-14T08:56:09 Z Baytoro Dango Maker (JOI18_dango_maker) C++17
100 / 100
626 ms 18076 KB
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define ll long long
#define int long long
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int INF=2e9,mod=1e9+7,N=2e5+10;
int dp[3005][5];
char c[3005][3005];
void solve(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>c[i][j];
		}
	}
	int ans=0;
	for(int s=2;s<=n+m;s++){
		int res=0;
		for(int i=1;i<=m;i++) dp[i][1]=dp[i][2]=0;
		for(int i=1;i<=m;i++){
			int j=s-i;
			if(j<1 || j>n) continue;
			dp[i][1]=max(dp[i-1][1],dp[i-1][2]);
			if(i>3)
				dp[i][2]=max(dp[i-1][2],dp[i-3][1]);
			if(j>2 && c[j-2][i]=='R' && c[j-1][i]=='G' && c[j][i]=='W')
				dp[i][1]=max(dp[i-1][2],dp[i-1][1])+1;
			if(i>2 && c[j][i-2]=='R' && c[j][i-1]=='G' && c[j][i]=='W')
				dp[i][2]=max(dp[i-1][2],dp[i-3][1])+1;
			res=max(res,max(dp[i][1],dp[i][2]));
		}
		ans+=res;
	}
	
	cout<<ans;
}
main(){
	//fopn("cbarn");
	//ios;
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
		//cout<<endl;
	}
}

Compilation message

dango_maker.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      | ^~~~
dango_maker.cpp: In function 'void fopn(std::string)':
dango_maker.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 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 1 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 304 KB Output is correct
26 Correct 0 ms 212 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 308 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 312 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 308 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 312 KB Output is correct
41 Correct 1 ms 340 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 0 ms 304 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 304 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 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 1 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 304 KB Output is correct
26 Correct 0 ms 212 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 308 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 312 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 308 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 312 KB Output is correct
41 Correct 1 ms 340 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 0 ms 304 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 304 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 16 ms 340 KB Output is correct
55 Correct 4 ms 9044 KB Output is correct
56 Correct 17 ms 340 KB Output is correct
57 Correct 5 ms 6100 KB Output is correct
58 Correct 70 ms 4252 KB Output is correct
59 Correct 626 ms 18024 KB Output is correct
60 Correct 618 ms 18024 KB Output is correct
61 Correct 618 ms 18056 KB Output is correct
62 Correct 14 ms 340 KB Output is correct
63 Correct 608 ms 17644 KB Output is correct
64 Correct 578 ms 17996 KB Output is correct
65 Correct 599 ms 17956 KB Output is correct
66 Correct 583 ms 18036 KB Output is correct
67 Correct 564 ms 18076 KB Output is correct
68 Correct 597 ms 18024 KB Output is correct
69 Correct 589 ms 18028 KB Output is correct
70 Correct 61 ms 4176 KB Output is correct
71 Correct 64 ms 4204 KB Output is correct
72 Correct 70 ms 4196 KB Output is correct
73 Correct 62 ms 4232 KB Output is correct
74 Correct 69 ms 4148 KB Output is correct
75 Correct 66 ms 4200 KB Output is correct
76 Correct 65 ms 4172 KB Output is correct
77 Correct 62 ms 4236 KB Output is correct
78 Correct 65 ms 4260 KB Output is correct
79 Correct 63 ms 4256 KB Output is correct
80 Correct 63 ms 4244 KB Output is correct
81 Correct 65 ms 4236 KB Output is correct
82 Correct 60 ms 4172 KB Output is correct
83 Correct 69 ms 4300 KB Output is correct
84 Correct 66 ms 4156 KB Output is correct
85 Correct 77 ms 4156 KB Output is correct
86 Correct 68 ms 4172 KB Output is correct
87 Correct 67 ms 4252 KB Output is correct
88 Correct 63 ms 4164 KB Output is correct
89 Correct 67 ms 4248 KB Output is correct
90 Correct 67 ms 4240 KB Output is correct