Submission #260302

# Submission time Handle Problem Language Result Execution time Memory
260302 2020-08-10T04:45:05 Z AM1648 Dango Maker (JOI18_dango_maker) C++17
0 / 100
1 ms 512 KB
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 3010;

ll n, m;
string A[maxn];
ll G[maxn][maxn];
ll col[maxn][maxn], cnt[2], ans;
ll adj[4][2] = {{-1, -1}, {-1, 1}, {1, -1}, {1, 1}};

void dfs(ll x, ll y, ll c) {
    col[x][y] = 1;
    if (G[x][y] == 3) cnt[0] += 1, cnt[1] += 1;
    else cnt[c] += 1;
    fori (i, 4) {
        ll xx = x + adj[i][0], yy = y + adj[i][1];
        if (!col[xx][yy] && (G[xx][yy] & 1) && (G[x][y] & 2)) dfs(xx, yy, c ^ 3);
        if (!col[xx][yy] && (G[xx][yy] & 2) && (G[x][y] & 1)) dfs(xx, yy, c ^ 3);
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n >> m;
    A[0] = A[n + 1] = string(m + 2, '.');
    fori (i, n) {
        cin >> A[i + 1];
        A[i + 1] = '.' + A[i + 1] + '.';
    }
    forifrom (i, 1, n + 1) {
        forifrom (j, 1, m + 1) {
            if (A[i][j] == 'G') {
                if (A[i][j - 1] == 'R' && A[i][j + 1] == 'W') G[i][j] ^= 1;
                if (A[i - 1][j] == 'R' && A[i + 1][j] == 'W') G[i][j] ^= 2;
            }
        }
    }
    forifrom (i, 1, n + 1) {
        forifrom (j, 1, m + 1) {
            if (G[i][j] && !col[i][j]) {
                cnt[0] = cnt[1] = 0;
                dfs(i, j, 1);
                ans += max(cnt[0], cnt[1]);
            }
        }
    }
    cout << ans << '\n';

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Incorrect 1 ms 512 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Incorrect 1 ms 512 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Incorrect 1 ms 512 KB Output isn't correct
7 Halted 0 ms 0 KB -