Submission #330206

# Submission time Handle Problem Language Result Execution time Memory
330206 2020-11-24T06:48:59 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 MAXN = 3000;
int n, m;
string mp[MAXN+1], ss;
int p[MAXN+1][MAXN+1];
int a, b;
int ans;
vector <vector<int>> path;
bool sy[MAXN+1];
bool vis[MAXN+1];

bool dfs(int now) {
  vis[now] = 1;
  for (int i : path[now]) {
    if (!sy[i] || (!vis[sy[i]] && dfs(sy[i]))) {
      sy[i] = now;
      return 1;
    }
  }
  return 0;
}

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;
  }
  path.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++;
        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++, path.pb(vector<int>());
        if (p[i][j  ]) path[b].pb(p[i][j  ]);
        if (p[i][j-1]) path[b].pb(p[i][j-1]);
        if (p[i][j-2]) path[b].pb(p[i][j-2]);
      }
    }
  }
  ans = a+b;
  for (int i = 1; i <= b; i++) {
    for (int j = 1; j <= b; j++) vis[j] = 0;
    vis[i] = 1;
    for (int j : path[i]) {
      if (!sy[j] || (!vis[sy[j]] && dfs(sy[j]))) {
        sy[j] = i;
        ans--;
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Compilation message

dango_maker.cpp:6:11: error: redefinition of 'const int MAXN'
    6 | const int MAXN = 3000;
      |           ^~~~
dango_maker.cpp:5:11: note: 'const int MAXN' previously defined here
    5 | const int MAXN = 3000;
      |           ^~~~