Submission #330216

# Submission time Handle Problem Language Result Execution time Memory
330216 2020-11-24T07:22:00 Z casperwang Dango Maker (JOI18_dango_maker) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

const int MAXN = 3000;
const int MAXM = 3000*3000;
int n, m;
string mp[MAXN+1], ss;
int p[MAXN+1][MAXN+1];
int a, b;
int ans;
vector <vector<int>> pathA, pathB;
int degA[MAXM+1];
int degB[MAXM+1];
bool visA[MAXM+1];
bool visB[MAXM+1];

void DFS(int now) {
  for (int i : pathB[now]) {
    if (visA[i]) continue;
    degA[i]--;
    visA[i] = 1;
    ans--;
    for (int j : pathA[i]) {
      if (visB[j]) continue;
      degB[j]--;
      if (degB[j] == 1) {
        visB[j] = 1;
        DFS(j);
      }
    }
  }
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> ss;
    mp[i] = ' ' + ss;
  }
  pathA.pb(vector<int>());
  pathB.pb(vector<int>());
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (i >= 3 && mp[i][j] == 'W' && mp[i-1][j] == 'G' && mp[i-2][j] == 'R') {
        a++;
        pathA.pb(vector<int>());
        p[i][j] = p[i-1][j] = p[i-2][j] = a;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (j >= 3 && mp[i][j] == 'W' && mp[i][j-1] == 'G' && mp[i][j-2] == 'R') {
        b++, pathB.pb(vector<int>());
        if (p[i][j]) {
          pathB[b].pb(p[i][j]);
          degB[b]++;
          pathA[p[i][j]].pb(b);
          degA[p[i][j]]++;
        }
        if (p[i][j-1]) {
          pathB[b].pb(p[i][j-1]);
          degB[b]++;
          pathA[p[i][j-1]].pb(b);
          degA[p[i][j-1]]++;
        }
        if (p[i][j-2]) {
          pathB[b].pb(p[i][j-2]);
          degB[b]++;
          pathA[p[i][j-2]].pb(b);
          degA[p[i][j-2]]++;
        }
      }
    }
  }
  ans = a+b;
  for (int i = 1; i <= b; i++) {
    if (degB[i] == 1 && !vis[i]) {
      visB[i] = 1;
      DFS(i);
    }
  }
  for (int i = 1; i <= b; i++) {
    if (degB[i] > 1) ans--;
  }
  cout << ans << "\n";
  return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:80:26: error: 'vis' was not declared in this scope; did you mean 'visB'?
   80 |     if (degB[i] == 1 && !vis[i]) {
      |                          ^~~
      |                          visB