답안 #43541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43541 2018-03-17T12:51:47 Z wxh010910 Dango Maker (JOI18_dango_maker) C++14
100 / 100
314 ms 121236 KB
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 3005;

int n, m, ans, f[N][3], g[N][N];
char s[N][N];

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), Read(m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i] + 1);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W') {
        g[i][j] |= 1;
      }
      if (s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W') {
        g[i][j] |= 2;
      }
    }
  }
  for (int s = 2; s <= n + m; ++s) {
    for (int i = max(1, s - m), j = s - i; i <= min(n, s - 1); ++i, --j) {
      if (i == max(1, s - m)) {
        f[i][0] = 0, f[i][1] = g[i][j] & 1, f[i][2] = g[i][j] >> 1 & 1;
      } else {
        f[i][0] = max(f[i - 1][0], max(f[i - 1][1], f[i - 1][2])), f[i][1] = f[i][2] = 0;
        if (g[i][j] & 1) {
          f[i][1] = max(f[i - 1][0], f[i - 1][1]) + 1;
        }
        if (g[i][j] & 2) {
          f[i][2] = max(f[i - 1][0], f[i - 1][2]) + 1;
        }
      }
    }
    ans += max(f[min(n, s - 1)][0], max(f[min(n, s - 1)][1], f[min(n, s - 1)][2]));
  }
  printf("%d\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:52:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s[i] + 1);
                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 1 ms 496 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 1 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 1 ms 696 KB Output is correct
12 Correct 2 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 2 ms 696 KB Output is correct
15 Correct 2 ms 696 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 1 ms 496 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 1 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 1 ms 696 KB Output is correct
12 Correct 2 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 2 ms 696 KB Output is correct
15 Correct 2 ms 696 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 740 KB Output is correct
28 Correct 1 ms 740 KB Output is correct
29 Correct 2 ms 740 KB Output is correct
30 Correct 1 ms 752 KB Output is correct
31 Correct 1 ms 832 KB Output is correct
32 Correct 1 ms 836 KB Output is correct
33 Correct 1 ms 836 KB Output is correct
34 Correct 1 ms 836 KB Output is correct
35 Correct 1 ms 836 KB Output is correct
36 Correct 1 ms 836 KB Output is correct
37 Correct 1 ms 836 KB Output is correct
38 Correct 1 ms 836 KB Output is correct
39 Correct 1 ms 836 KB Output is correct
40 Correct 2 ms 836 KB Output is correct
41 Correct 1 ms 836 KB Output is correct
42 Correct 2 ms 836 KB Output is correct
43 Correct 1 ms 836 KB Output is correct
44 Correct 1 ms 836 KB Output is correct
45 Correct 2 ms 864 KB Output is correct
46 Correct 2 ms 864 KB Output is correct
47 Correct 1 ms 864 KB Output is correct
48 Correct 1 ms 864 KB Output is correct
49 Correct 2 ms 864 KB Output is correct
50 Correct 2 ms 864 KB Output is correct
51 Correct 2 ms 864 KB Output is correct
52 Correct 2 ms 864 KB Output is correct
53 Correct 1 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 1 ms 496 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 1 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 1 ms 696 KB Output is correct
12 Correct 2 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 2 ms 696 KB Output is correct
15 Correct 2 ms 696 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 740 KB Output is correct
28 Correct 1 ms 740 KB Output is correct
29 Correct 2 ms 740 KB Output is correct
30 Correct 1 ms 752 KB Output is correct
31 Correct 1 ms 832 KB Output is correct
32 Correct 1 ms 836 KB Output is correct
33 Correct 1 ms 836 KB Output is correct
34 Correct 1 ms 836 KB Output is correct
35 Correct 1 ms 836 KB Output is correct
36 Correct 1 ms 836 KB Output is correct
37 Correct 1 ms 836 KB Output is correct
38 Correct 1 ms 836 KB Output is correct
39 Correct 1 ms 836 KB Output is correct
40 Correct 2 ms 836 KB Output is correct
41 Correct 1 ms 836 KB Output is correct
42 Correct 2 ms 836 KB Output is correct
43 Correct 1 ms 836 KB Output is correct
44 Correct 1 ms 836 KB Output is correct
45 Correct 2 ms 864 KB Output is correct
46 Correct 2 ms 864 KB Output is correct
47 Correct 1 ms 864 KB Output is correct
48 Correct 1 ms 864 KB Output is correct
49 Correct 2 ms 864 KB Output is correct
50 Correct 2 ms 864 KB Output is correct
51 Correct 2 ms 864 KB Output is correct
52 Correct 2 ms 864 KB Output is correct
53 Correct 1 ms 864 KB Output is correct
54 Correct 2 ms 864 KB Output is correct
55 Correct 10 ms 10072 KB Output is correct
56 Correct 2 ms 10072 KB Output is correct
57 Correct 11 ms 13824 KB Output is correct
58 Correct 34 ms 13824 KB Output is correct
59 Correct 314 ms 54992 KB Output is correct
60 Correct 274 ms 63756 KB Output is correct
61 Correct 283 ms 72432 KB Output is correct
62 Correct 2 ms 72432 KB Output is correct
63 Correct 280 ms 81124 KB Output is correct
64 Correct 202 ms 89988 KB Output is correct
65 Correct 230 ms 98664 KB Output is correct
66 Correct 199 ms 107664 KB Output is correct
67 Correct 166 ms 107664 KB Output is correct
68 Correct 153 ms 107664 KB Output is correct
69 Correct 177 ms 120076 KB Output is correct
70 Correct 28 ms 120076 KB Output is correct
71 Correct 25 ms 120076 KB Output is correct
72 Correct 22 ms 120076 KB Output is correct
73 Correct 26 ms 120076 KB Output is correct
74 Correct 24 ms 120076 KB Output is correct
75 Correct 21 ms 120076 KB Output is correct
76 Correct 24 ms 120076 KB Output is correct
77 Correct 21 ms 120076 KB Output is correct
78 Correct 23 ms 120076 KB Output is correct
79 Correct 22 ms 120076 KB Output is correct
80 Correct 22 ms 120076 KB Output is correct
81 Correct 22 ms 120076 KB Output is correct
82 Correct 21 ms 120076 KB Output is correct
83 Correct 24 ms 120076 KB Output is correct
84 Correct 22 ms 120076 KB Output is correct
85 Correct 21 ms 120076 KB Output is correct
86 Correct 21 ms 120076 KB Output is correct
87 Correct 20 ms 120076 KB Output is correct
88 Correct 20 ms 120076 KB Output is correct
89 Correct 22 ms 120256 KB Output is correct
90 Correct 21 ms 121236 KB Output is correct