답안 #680114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680114 2023-01-09T23:44:37 Z tvladm2009 Dango Maker (JOI18_dango_maker) C++14
100 / 100
274 ms 35756 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = (int) 3e3 + 7;
char a[N][N];
bool horizontal[N][N];
bool vertical[N][N];

int main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif // ONPC

#ifndef ONPC
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif // ONPC

  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= m; j++)
    {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= m; j++)
    {
      if (a[i][j] == 'G')
      {
        if (j > 1 && j < m && a[i][j - 1] == 'R' && a[i][j + 1] == 'W')
        {
          horizontal[i][j] = true;
        }
        if (i > 1 && i < n && a[i - 1][j] == 'R' && a[i + 1][j] == 'W')
        {
          vertical[i][j] = true;
        }
      }
    }
  }
  int sol = 0;
  for (int i = 2; i <= n + m; i++)
  {
    int i1 = max(1, i - m), i2 = min(n, i - 1);
    vector<vector<int>> dp(2, vector<int>(3));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (int lin = i1; lin <= i2; lin++)
    {
      int col = i - lin;
      dp[1][0] = max({dp[0][0], dp[0][1], dp[0][2]});
      if (horizontal[lin][col] == true)
      {
        dp[1][1] = max(dp[0][0], dp[0][1]) + 1;
      }
      else
      {
        dp[1][1] = 0;
      }
      if (vertical[lin][col] == true)
      {
        dp[1][2] = max(dp[0][0], dp[0][2]) + 1;
      }
      else
      {
        dp[1][2] = 0;
      }
      swap(dp[0], dp[1]);
    }
    sol += max({dp[0][0], dp[0][1], dp[0][2]});
  }
  cout << sol;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 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 340 KB Output is correct
26 Correct 0 ms 332 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 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 0 ms 332 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 340 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 336 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 340 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 1 ms 340 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 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 340 KB Output is correct
26 Correct 0 ms 332 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 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 0 ms 332 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 340 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 336 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 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 6 ms 9588 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 6 ms 14556 KB Output is correct
58 Correct 31 ms 10060 KB Output is correct
59 Correct 254 ms 35580 KB Output is correct
60 Correct 267 ms 35716 KB Output is correct
61 Correct 254 ms 35492 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 274 ms 35332 KB Output is correct
64 Correct 201 ms 35528 KB Output is correct
65 Correct 228 ms 35480 KB Output is correct
66 Correct 210 ms 35756 KB Output is correct
67 Correct 201 ms 25008 KB Output is correct
68 Correct 196 ms 25004 KB Output is correct
69 Correct 208 ms 31444 KB Output is correct
70 Correct 22 ms 10108 KB Output is correct
71 Correct 25 ms 10080 KB Output is correct
72 Correct 22 ms 10068 KB Output is correct
73 Correct 24 ms 10100 KB Output is correct
74 Correct 22 ms 10108 KB Output is correct
75 Correct 23 ms 10120 KB Output is correct
76 Correct 22 ms 10124 KB Output is correct
77 Correct 22 ms 10084 KB Output is correct
78 Correct 26 ms 10100 KB Output is correct
79 Correct 22 ms 10260 KB Output is correct
80 Correct 21 ms 10096 KB Output is correct
81 Correct 23 ms 10096 KB Output is correct
82 Correct 22 ms 10116 KB Output is correct
83 Correct 22 ms 10232 KB Output is correct
84 Correct 23 ms 10068 KB Output is correct
85 Correct 23 ms 10108 KB Output is correct
86 Correct 22 ms 10128 KB Output is correct
87 Correct 30 ms 10096 KB Output is correct
88 Correct 22 ms 10068 KB Output is correct
89 Correct 22 ms 10024 KB Output is correct
90 Correct 22 ms 10064 KB Output is correct