# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
644221 | 2022-09-24T05:36:49 Z | ghostwriter | Dango Maker (JOI18_dango_maker) | C++14 | 413 ms | 230632 KB |
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #endif #define ft front #define bk back #define st first #define nd second #define ins insert #define ers erase #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define bg begin #define ed end #define all(x) (x).bg(), (x).ed() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao VOI23 gold medal */ const int N = 3015; int n, m, p1[N][N], p2[N][N], d[N][N][3], c[N][N], rs = 0; char a[N][N]; signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen(file".inp", "r", stdin) // freopen(file".out", "w", stdout); cin >> n >> m; FOR(i, 1, n) FOR(j, 1, m) cin >> a[i + 3][j + 3]; FOR(i, 3, n + 3) FOR(j, 3, m + 3) { if (a[i][j] != 'R' || a[i][j + 1] != 'G' || a[i][j + 2] != 'W') continue; p1[i][j] = 1; } FOR(i, 3, n + 3) FOR(j, 3, m + 3) { if (a[i][j] != 'R' || a[i + 1][j] != 'G' || a[i + 2][j] != 'W') continue; p2[i][j] = 1; } FOR(i, 1, n + 3) FOR(j, 1, m + 3) FOR(z, 0, 2) { d[i][j][z] = max(d[i][j][z], d[i - 1][j + 1][min(2, z + 1)]); if (p1[i][j]) d[i][j][z] = max(d[i][j][z], d[i - 1][j + 1][0] + 1); if (z == 2 && p2[i][j]) d[i][j][z] = max(d[i][j][z], d[i - 1][j + 1][2] + 1); } FOR(i, 1, n + 3) FOR(j, 1, m + 3) { if (c[i][j]) continue; int x = i, y = j; WHILE(x <= n + 3 && y >= 1) { c[x][y] = 1; ++x; --y; } --x; ++y; rs += d[x][y][0]; } cout << rs; return 0; } /* 4 4 RGWR GRRG WGGW WWWR */ /* From Benq: stuff you should look for * int overflow, array bounds * special cases (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 0 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 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 | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 0 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 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 | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 468 KB | Output is correct |
20 | Correct | 1 ms | 464 KB | Output is correct |
21 | Correct | 1 ms | 464 KB | Output is correct |
22 | Correct | 1 ms | 468 KB | Output is correct |
23 | Correct | 1 ms | 460 KB | Output is correct |
24 | Correct | 1 ms | 468 KB | Output is correct |
25 | Correct | 1 ms | 468 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 468 KB | Output is correct |
28 | Correct | 1 ms | 468 KB | Output is correct |
29 | Correct | 1 ms | 468 KB | Output is correct |
30 | Correct | 1 ms | 464 KB | Output is correct |
31 | Correct | 0 ms | 468 KB | Output is correct |
32 | Correct | 1 ms | 468 KB | Output is correct |
33 | Correct | 1 ms | 468 KB | Output is correct |
34 | Correct | 1 ms | 460 KB | Output is correct |
35 | Correct | 1 ms | 464 KB | Output is correct |
36 | Correct | 1 ms | 468 KB | Output is correct |
37 | Correct | 1 ms | 468 KB | Output is correct |
38 | Correct | 1 ms | 464 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 1 ms | 468 KB | Output is correct |
41 | Correct | 1 ms | 468 KB | Output is correct |
42 | Correct | 1 ms | 468 KB | Output is correct |
43 | Correct | 1 ms | 468 KB | Output is correct |
44 | Correct | 1 ms | 468 KB | Output is correct |
45 | Correct | 1 ms | 468 KB | Output is correct |
46 | Correct | 1 ms | 468 KB | Output is correct |
47 | Correct | 1 ms | 464 KB | Output is correct |
48 | Correct | 0 ms | 468 KB | Output is correct |
49 | Correct | 1 ms | 468 KB | Output is correct |
50 | Correct | 1 ms | 468 KB | Output is correct |
51 | Correct | 1 ms | 464 KB | Output is correct |
52 | Correct | 1 ms | 468 KB | Output is correct |
53 | Correct | 1 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 0 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 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 | 0 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 0 ms | 468 KB | Output is correct |
20 | Correct | 1 ms | 464 KB | Output is correct |
21 | Correct | 1 ms | 464 KB | Output is correct |
22 | Correct | 1 ms | 468 KB | Output is correct |
23 | Correct | 1 ms | 460 KB | Output is correct |
24 | Correct | 1 ms | 468 KB | Output is correct |
25 | Correct | 1 ms | 468 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 468 KB | Output is correct |
28 | Correct | 1 ms | 468 KB | Output is correct |
29 | Correct | 1 ms | 468 KB | Output is correct |
30 | Correct | 1 ms | 464 KB | Output is correct |
31 | Correct | 0 ms | 468 KB | Output is correct |
32 | Correct | 1 ms | 468 KB | Output is correct |
33 | Correct | 1 ms | 468 KB | Output is correct |
34 | Correct | 1 ms | 460 KB | Output is correct |
35 | Correct | 1 ms | 464 KB | Output is correct |
36 | Correct | 1 ms | 468 KB | Output is correct |
37 | Correct | 1 ms | 468 KB | Output is correct |
38 | Correct | 1 ms | 464 KB | Output is correct |
39 | Correct | 1 ms | 468 KB | Output is correct |
40 | Correct | 1 ms | 468 KB | Output is correct |
41 | Correct | 1 ms | 468 KB | Output is correct |
42 | Correct | 1 ms | 468 KB | Output is correct |
43 | Correct | 1 ms | 468 KB | Output is correct |
44 | Correct | 1 ms | 468 KB | Output is correct |
45 | Correct | 1 ms | 468 KB | Output is correct |
46 | Correct | 1 ms | 468 KB | Output is correct |
47 | Correct | 1 ms | 464 KB | Output is correct |
48 | Correct | 0 ms | 468 KB | Output is correct |
49 | Correct | 1 ms | 468 KB | Output is correct |
50 | Correct | 1 ms | 468 KB | Output is correct |
51 | Correct | 1 ms | 464 KB | Output is correct |
52 | Correct | 1 ms | 468 KB | Output is correct |
53 | Correct | 1 ms | 460 KB | Output is correct |
54 | Correct | 1 ms | 468 KB | Output is correct |
55 | Correct | 19 ms | 34124 KB | Output is correct |
56 | Correct | 1 ms | 852 KB | Output is correct |
57 | Correct | 15 ms | 32744 KB | Output is correct |
58 | Correct | 50 ms | 43588 KB | Output is correct |
59 | Correct | 412 ms | 230504 KB | Output is correct |
60 | Correct | 391 ms | 230632 KB | Output is correct |
61 | Correct | 411 ms | 230504 KB | Output is correct |
62 | Correct | 1 ms | 596 KB | Output is correct |
63 | Correct | 413 ms | 230120 KB | Output is correct |
64 | Correct | 330 ms | 230476 KB | Output is correct |
65 | Correct | 319 ms | 230604 KB | Output is correct |
66 | Correct | 303 ms | 230444 KB | Output is correct |
67 | Correct | 295 ms | 175532 KB | Output is correct |
68 | Correct | 300 ms | 175644 KB | Output is correct |
69 | Correct | 297 ms | 185616 KB | Output is correct |
70 | Correct | 39 ms | 43896 KB | Output is correct |
71 | Correct | 37 ms | 43980 KB | Output is correct |
72 | Correct | 39 ms | 43892 KB | Output is correct |
73 | Correct | 37 ms | 43864 KB | Output is correct |
74 | Correct | 38 ms | 43804 KB | Output is correct |
75 | Correct | 38 ms | 43888 KB | Output is correct |
76 | Correct | 37 ms | 43868 KB | Output is correct |
77 | Correct | 43 ms | 43876 KB | Output is correct |
78 | Correct | 43 ms | 43900 KB | Output is correct |
79 | Correct | 38 ms | 43860 KB | Output is correct |
80 | Correct | 39 ms | 43904 KB | Output is correct |
81 | Correct | 37 ms | 43872 KB | Output is correct |
82 | Correct | 38 ms | 43856 KB | Output is correct |
83 | Correct | 38 ms | 43852 KB | Output is correct |
84 | Correct | 40 ms | 43784 KB | Output is correct |
85 | Correct | 47 ms | 43840 KB | Output is correct |
86 | Correct | 41 ms | 43808 KB | Output is correct |
87 | Correct | 38 ms | 43960 KB | Output is correct |
88 | Correct | 39 ms | 43788 KB | Output is correct |
89 | Correct | 40 ms | 43896 KB | Output is correct |
90 | Correct | 38 ms | 43848 KB | Output is correct |