Submission #958889

# Submission time Handle Problem Language Result Execution time Memory
958889 2024-04-07T02:53:37 Z Maaxle Dango Maker (JOI18_dango_maker) C++17
13 / 100
17 ms 37724 KB
#include <bits/stdc++.h>

#define range(it, a, b) for (ll it = a; it < b; it++)
#define all(x) begin(x), end(x)
#define ll long long
#define ull unsigned long long
#define INF64 ((ll) 1 << 62)
#define INF32 (1 << 30)
#define mset multiset
#define uset unordered_set
#define umap unordered_map 
#define pqueue priority_queue 
#define ptr(A) shared_ptr<A>

using namespace std;

void setio (string name) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (name.size()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

ll n, m;
char mat[(ll)3e3][(ll)3e3];
int memo[(ll)3e3][(ll)3e3];
vector<vector<ll>> adj;

void solve() {
    cin >> n >> m;
    memset(memo, -1, sizeof(memo));

    range(i, 0, n) {
        range(j, 0, m) 
            cin >> mat[i][j];
    }

    ll cnt = 0;
    range(i, 0, n-2) {
        range(j, 0, m) {
            if (mat[i][j] == 'R' && mat[i+1][j] == 'G' && mat[i+2][j] == 'W') {
                adj.push_back({-1, -1, -1});
                memo[i][j] = memo[i+1][j] = memo[i+2][j] = cnt;
                cnt++;
            }   
        }
    }

    range(i, 0, n) {
        range(j, 0, m-2) {
            if (mat[i][j] == 'R' && mat[i][j+1] == 'G' && mat[i][j+2] == 'W') {
                adj.push_back({memo[i][j], memo[i][j+1], memo[i][j+2]});
                if (memo[i][j] != -1)
                    adj[memo[i][j]][0] = cnt;
                if (memo[i][j+1] != -1)
                    adj[memo[i][j+1]][1] = cnt;
                if (memo[i][j+2] != -1)
                    adj[memo[i][j+2]][2] = cnt;
                cnt++;
            }   
        }
    }

    ll ans = cnt;
    range(i, 0, adj.size()) {
        if ((0+(adj[i][0] != -1)+(adj[i][1] != -1)+(adj[i][2] != -1)) == 3) {
            ans--;
            adj[adj[i][0]][0] = -1;
            adj[adj[i][1]][1] = -1;
            adj[adj[i][2]][2] = -1;
            adj[i] = {-1, -1, -1};
        }
    }
    range(i, 0, adj.size()) {
        if ((0+(adj[i][0] != -1)+(adj[i][1] != -1)+(adj[i][2] != -1)) == 2) {
            ans--;
            if (adj[i][0] != -1)
                adj[adj[i][0]][0] = -1;
            if (adj[i][1] != -1)
                adj[adj[i][1]][1] = -1;
            if (adj[i][2] != -1)
                adj[adj[i][2]][2] = -1;
            adj[i] = {-1, -1, -1};
        }
    }
    range(i, 0, adj.size()) {
        if ((0+(adj[i][0] != -1)+(adj[i][1] != -1)+(adj[i][2] != -1)) == 1) {
            ans--;
            if (adj[i][0] != -1)
                adj[adj[i][0]][0] = -1;
            if (adj[i][1] != -1)
                adj[adj[i][1]][1] = -1;
            if (adj[i][2] != -1)
                adj[adj[i][2]][2] = -1;
            adj[i] = {-1, -1, -1};
        }
    }
    cout << ans;
}

int main () {
    setio("");
    ll t = 1; 
    // cin >> t;
    while (t--) solve();
}

// IT'S TOUGH, I KNOW
// BUT YOU'D RATHER DIE FIGHTING THAN LIVE ON YOUR KNEES
// THOUG H YOU WON'T DO NEITHER OF THOSE
// IMPOSSIBLE, AS IT'S AGAINST YOUR NATURE
// AS YOU ALREADY WON
// I SEE YOUR MEDAL HANGING FROM YOUR NECK
// SHINING AS NOTHING YOU'VE EVER HAD

// THOUSANDS AND THOUSANDS OF LINES
// YOU AREADY MADE IT THIS FAR
// AND WHO COULD TELL HOW FAR YOU WILL GET...
// BUT YOU?

// THEN COME ON, YOU BASTARD!
// GO CLEAR YOUR MIND AND STAND
// AS EACH OF THOSE LINES IS A STEP CLOSER
// CLOSER TO THE GREATNESS YOU PURSUE
// CLOSER TO THE GREATNESS YOU ALREADY HAVE

Compilation message

dango_maker.cpp: In function 'void solve()':
dango_maker.cpp:3:44: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define range(it, a, b) for (ll it = a; it < b; it++)
......
   67 |     range(i, 0, adj.size()) {
      |           ~~~~~~~~~~~~~~~~                  
dango_maker.cpp:67:5: note: in expansion of macro 'range'
   67 |     range(i, 0, adj.size()) {
      |     ^~~~~
dango_maker.cpp:3:44: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define range(it, a, b) for (ll it = a; it < b; it++)
......
   76 |     range(i, 0, adj.size()) {
      |           ~~~~~~~~~~~~~~~~                  
dango_maker.cpp:76:5: note: in expansion of macro 'range'
   76 |     range(i, 0, adj.size()) {
      |     ^~~~~
dango_maker.cpp:3:44: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define range(it, a, b) for (ll it = a; it < b; it++)
......
   88 |     range(i, 0, adj.size()) {
      |           ~~~~~~~~~~~~~~~~                  
dango_maker.cpp:88:5: note: in expansion of macro 'range'
   88 |     range(i, 0, adj.size()) {
      |     ^~~~~
dango_maker.cpp: In function 'void setio(std::string)':
dango_maker.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 17 ms 37468 KB Output is correct
2 Correct 6 ms 37464 KB Output is correct
3 Correct 5 ms 37468 KB Output is correct
4 Correct 5 ms 37464 KB Output is correct
5 Correct 5 ms 37724 KB Output is correct
6 Correct 5 ms 37464 KB Output is correct
7 Correct 5 ms 37468 KB Output is correct
8 Correct 6 ms 37468 KB Output is correct
9 Correct 5 ms 37468 KB Output is correct
10 Correct 5 ms 37468 KB Output is correct
11 Correct 5 ms 37528 KB Output is correct
12 Correct 5 ms 37464 KB Output is correct
13 Correct 5 ms 37464 KB Output is correct
14 Correct 5 ms 37464 KB Output is correct
15 Correct 5 ms 37464 KB Output is correct
16 Correct 5 ms 37468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 37468 KB Output is correct
2 Correct 6 ms 37464 KB Output is correct
3 Correct 5 ms 37468 KB Output is correct
4 Correct 5 ms 37464 KB Output is correct
5 Correct 5 ms 37724 KB Output is correct
6 Correct 5 ms 37464 KB Output is correct
7 Correct 5 ms 37468 KB Output is correct
8 Correct 6 ms 37468 KB Output is correct
9 Correct 5 ms 37468 KB Output is correct
10 Correct 5 ms 37468 KB Output is correct
11 Correct 5 ms 37528 KB Output is correct
12 Correct 5 ms 37464 KB Output is correct
13 Correct 5 ms 37464 KB Output is correct
14 Correct 5 ms 37464 KB Output is correct
15 Correct 5 ms 37464 KB Output is correct
16 Correct 5 ms 37468 KB Output is correct
17 Correct 6 ms 37468 KB Output is correct
18 Correct 5 ms 37468 KB Output is correct
19 Correct 5 ms 37560 KB Output is correct
20 Incorrect 5 ms 37468 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 37468 KB Output is correct
2 Correct 6 ms 37464 KB Output is correct
3 Correct 5 ms 37468 KB Output is correct
4 Correct 5 ms 37464 KB Output is correct
5 Correct 5 ms 37724 KB Output is correct
6 Correct 5 ms 37464 KB Output is correct
7 Correct 5 ms 37468 KB Output is correct
8 Correct 6 ms 37468 KB Output is correct
9 Correct 5 ms 37468 KB Output is correct
10 Correct 5 ms 37468 KB Output is correct
11 Correct 5 ms 37528 KB Output is correct
12 Correct 5 ms 37464 KB Output is correct
13 Correct 5 ms 37464 KB Output is correct
14 Correct 5 ms 37464 KB Output is correct
15 Correct 5 ms 37464 KB Output is correct
16 Correct 5 ms 37468 KB Output is correct
17 Correct 6 ms 37468 KB Output is correct
18 Correct 5 ms 37468 KB Output is correct
19 Correct 5 ms 37560 KB Output is correct
20 Incorrect 5 ms 37468 KB Output isn't correct
21 Halted 0 ms 0 KB -