Submission #644221

#TimeUsernameProblemLanguageResultExecution timeMemory
644221ghostwriterDango Maker (JOI18_dango_maker)C++14
100 / 100
413 ms230632 KiB
#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 (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:49:5: note: in expansion of macro 'FOR'
   49 |     FOR(i, 1, n)
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:50:5: note: in expansion of macro 'FOR'
   50 |     FOR(j, 1, m)
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:52:5: note: in expansion of macro 'FOR'
   52 |     FOR(i, 3, n + 3)
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:53:5: note: in expansion of macro 'FOR'
   53 |     FOR(j, 3, m + 3) {
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:57:5: note: in expansion of macro 'FOR'
   57 |     FOR(i, 3, n + 3)
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:58:5: note: in expansion of macro 'FOR'
   58 |     FOR(j, 3, m + 3) {
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:62:5: note: in expansion of macro 'FOR'
   62 |     FOR(i, 1, n + 3)
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:63:5: note: in expansion of macro 'FOR'
   63 |     FOR(j, 1, m + 3)
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'z' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:64:5: note: in expansion of macro 'FOR'
   64 |     FOR(z, 0, 2) {
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:69:5: note: in expansion of macro 'FOR'
   69 |     FOR(i, 1, n + 3)
      |     ^~~
dango_maker.cpp:30:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   30 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
dango_maker.cpp:70:5: note: in expansion of macro 'FOR'
   70 |     FOR(j, 1, m + 3) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...