답안 #255219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255219 2020-07-31T15:10:22 Z uacoder123 Dango Maker (JOI18_dango_maker) C++14
33 / 100
166 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
 
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
int n,m;
ii arr[3000][3000];
char arr1[3000][3000];
int dp[3001][3001][3][3];
int cal(int i,int j,int k,int l)
{
  if(dp[i][j][k][l]!=-1)
    return(dp[i][j][k][l]);
  dp[i][j][k][l]=0;
  if(i==n||j==m)
    return(0);
  int ans=0;
  ans=cal(i+1,j+1,0,k);
  if(arr[i][j].F==1)
    ans=max(ans,1+cal(i+1,j+1,1,k));
  if(arr[i][j].S==1&&k!=1&&l!=1)
  {
    ans=max(ans,1+cal(i+1,j+1,2,k));
  }
  dp[i][j][k][l]=ans;
  return(dp[i][j][k][l]);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>n>>m;
  for(int i=0;i<n;++i)
    for(int j=0;j<m;++j)
      for(int k=0;k<3;++k)
        for(int l=0;l<3;++l)
          dp[i][j][k][l]=-1;
  for(int i=n-1;i>=0;--i)
    for(int j=0;j<m;++j)
      cin>>arr1[i][j];
  for(int i=0;i<n;++i)
  {
    for(int j=0;j<m;++j)
    {
      arr[i][j]=mp(0,0);
      if(i>1&&arr1[i][j]=='R'&&arr1[i-1][j]=='G'&&arr1[i-2][j]=='W')
        arr[i][j].S=1;
      if(j+2<m&&arr1[i][j]=='R'&&arr1[i][j+1]=='G'&&arr1[i][j+2]=='W')
        arr[i][j].F=1;
    }
  }
  int ans=0;
  for(int i=0;i<n;++i)
    ans+=cal(i,0,0,0);
  for(int j=1;j<m;++j)
    ans+=cal(0,j,0,0);
  cout<<ans<<endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 512 KB Output is correct
21 Correct 0 ms 512 KB Output is correct
22 Correct 0 ms 512 KB Output is correct
23 Correct 0 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 0 ms 512 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 388 KB Output is correct
28 Correct 0 ms 512 KB Output is correct
29 Correct 0 ms 512 KB Output is correct
30 Correct 0 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 0 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 0 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 0 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 512 KB Output is correct
21 Correct 0 ms 512 KB Output is correct
22 Correct 0 ms 512 KB Output is correct
23 Correct 0 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 0 ms 512 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 388 KB Output is correct
28 Correct 0 ms 512 KB Output is correct
29 Correct 0 ms 512 KB Output is correct
30 Correct 0 ms 512 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 0 ms 512 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 0 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 0 ms 512 KB Output is correct
54 Correct 1 ms 512 KB Output is correct
55 Correct 16 ms 34176 KB Output is correct
56 Correct 2 ms 1152 KB Output is correct
57 Correct 13 ms 23680 KB Output is correct
58 Correct 96 ms 63480 KB Output is correct
59 Runtime error 166 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
60 Halted 0 ms 0 KB -