Submission #459563

#TimeUsernameProblemLanguageResultExecution timeMemory
459563TeaTimeDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms332 KiB
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SZ = 3050;

char grid[SZ][SZ];

int main() {
    fastInp;

    ll n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) grid[i][j] = s[j];
    }

    ll ans = 0;
    map<ll, ll> cnt;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (grid[i][j] == 'R') {
                if (grid[i][j + 1] == 'G' && grid[i][j + 2] == 'W') {
                    cnt['R']++;
                    continue;
                }
                if (grid[i + 1][j] == 'G' && grid[i + 2][j] == 'W') {
                    cnt['R']++;
                    continue;
                }
            } else if (grid[i][j] == 'G') {
                if (j > 0 && grid[i][j - 1] == 'R' && grid[i][j + 1] == 'W') {
                    cnt['G']++;
                    continue;
                }
                if (i > 0 && grid[i - 1][j] == 'R' && grid[i + 1][j] == 'W') {
                    cnt['G']++;
                    continue;
                }
            } else {
                if (j > 1 && grid[i][j - 2] == 'R' && grid[i][j - 1] == 'G') {
                    cnt['W']++;
                    continue;
                }
                if (i > 1 && grid[i - 2][j] == 'R' && grid[i - 1][j] == 'G') {
                    cnt['W']++;
                    continue;
                }
            }
        }
    }

    cout << min(min(cnt['R'], cnt['G']), cnt['W']);

    return 0;
}

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:35:8: warning: unused variable 'ans' [-Wunused-variable]
   35 |     ll ans = 0;
      |        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...