Submission #92335

# Submission time Handle Problem Language Result Execution time Memory
92335 2019-01-02T14:00:17 Z karma Dango Maker (JOI18_dango_maker) C++11
100 / 100
266 ms 44664 KB
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 3e3 + 7;

int n, m, res, f[N][3], ptr;
bool p[N][N][3];
string s[N];
vector<pii> v;

void Enter()
{
     cin >> n >> m;
     For(i, 1, n)
     {
         cin >> s[i];
         s[i] = ' ' + s[i];
     }
     For(i, 1, n)
     {
         For(j, 1, m)
         {
             if(s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W') p[i][j][1] = 1;
             if(s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W') p[i][j][2] = 1;
         }
     }
}

void Solve()
{
     v.resize(m + n + 1);
     res = 0;
     For(i, 2, n + m)
     {
         int ptr = 0;
         For(j, 1, n)
         {
            int k = i - j;
            if(k > 0 && k <= m) v[++ptr] = {j, k};
         }
         memset(&f, 0, sizeof f);
         For(j, 1, ptr)
         {
             f[j][0] = max({f[j - 1][0], f[j - 1][1], f[j - 1][2]});
             if(p[v[j].X][v[j].Y][1]) f[j][1] = max(f[j - 1][0], f[j - 1][1]) + 1;
             if(p[v[j].X][v[j].Y][2]) f[j][2] = max(f[j - 1][0], f[j - 1][2]) + 1;
         }
         res += max({f[ptr][0], f[ptr][1], f[ptr][2]});
     }
     cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 508 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 4 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 508 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 4 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 504 KB Output is correct
30 Correct 2 ms 504 KB Output is correct
31 Correct 2 ms 508 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 2 ms 504 KB Output is correct
40 Correct 2 ms 504 KB Output is correct
41 Correct 2 ms 504 KB Output is correct
42 Correct 2 ms 504 KB Output is correct
43 Correct 2 ms 504 KB Output is correct
44 Correct 2 ms 508 KB Output is correct
45 Correct 2 ms 504 KB Output is correct
46 Correct 2 ms 592 KB Output is correct
47 Correct 2 ms 504 KB Output is correct
48 Correct 2 ms 504 KB Output is correct
49 Correct 2 ms 504 KB Output is correct
50 Correct 2 ms 504 KB Output is correct
51 Correct 2 ms 504 KB Output is correct
52 Correct 2 ms 504 KB Output is correct
53 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 508 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 4 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 504 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 504 KB Output is correct
30 Correct 2 ms 504 KB Output is correct
31 Correct 2 ms 508 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 2 ms 504 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 504 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 2 ms 504 KB Output is correct
38 Correct 2 ms 504 KB Output is correct
39 Correct 2 ms 504 KB Output is correct
40 Correct 2 ms 504 KB Output is correct
41 Correct 2 ms 504 KB Output is correct
42 Correct 2 ms 504 KB Output is correct
43 Correct 2 ms 504 KB Output is correct
44 Correct 2 ms 508 KB Output is correct
45 Correct 2 ms 504 KB Output is correct
46 Correct 2 ms 592 KB Output is correct
47 Correct 2 ms 504 KB Output is correct
48 Correct 2 ms 504 KB Output is correct
49 Correct 2 ms 504 KB Output is correct
50 Correct 2 ms 504 KB Output is correct
51 Correct 2 ms 504 KB Output is correct
52 Correct 2 ms 504 KB Output is correct
53 Correct 2 ms 504 KB Output is correct
54 Correct 6 ms 504 KB Output is correct
55 Correct 17 ms 1020 KB Output is correct
56 Correct 6 ms 504 KB Output is correct
57 Correct 14 ms 7544 KB Output is correct
58 Correct 34 ms 8484 KB Output is correct
59 Correct 241 ms 36028 KB Output is correct
60 Correct 264 ms 35960 KB Output is correct
61 Correct 265 ms 36052 KB Output is correct
62 Correct 6 ms 504 KB Output is correct
63 Correct 266 ms 44020 KB Output is correct
64 Correct 194 ms 44664 KB Output is correct
65 Correct 189 ms 44664 KB Output is correct
66 Correct 189 ms 44640 KB Output is correct
67 Correct 142 ms 31096 KB Output is correct
68 Correct 147 ms 31096 KB Output is correct
69 Correct 164 ms 36088 KB Output is correct
70 Correct 26 ms 9436 KB Output is correct
71 Correct 22 ms 9464 KB Output is correct
72 Correct 21 ms 9464 KB Output is correct
73 Correct 20 ms 9464 KB Output is correct
74 Correct 21 ms 9464 KB Output is correct
75 Correct 21 ms 9592 KB Output is correct
76 Correct 20 ms 9464 KB Output is correct
77 Correct 22 ms 9468 KB Output is correct
78 Correct 26 ms 9468 KB Output is correct
79 Correct 22 ms 9464 KB Output is correct
80 Correct 23 ms 9464 KB Output is correct
81 Correct 26 ms 9592 KB Output is correct
82 Correct 24 ms 9464 KB Output is correct
83 Correct 22 ms 9464 KB Output is correct
84 Correct 20 ms 9464 KB Output is correct
85 Correct 25 ms 9532 KB Output is correct
86 Correct 24 ms 9464 KB Output is correct
87 Correct 25 ms 9464 KB Output is correct
88 Correct 25 ms 9464 KB Output is correct
89 Correct 22 ms 9464 KB Output is correct
90 Correct 21 ms 9464 KB Output is correct