Submission #1102092

#TimeUsernameProblemLanguageResultExecution timeMemory
1102092_8_8_Dango Maker (JOI18_dango_maker)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 3e3 + 12, MOD = 998244353; char a[N][N]; int n, m, res = 0, res1 = 0, v[N][N], it = 1, h[N][N], dp[N * N]; vector<int> g[N * N]; void add(int x, int y) { g[x].push_back(y); g[y].push_back(x); } bool vis[N * N]; void dfs(int v, int pr = -1) { vis[v] = 1; dp[v][1] = 1; for(int to:g[v]) { if(to == pr || vis[to]) continue; dfs(to, v); dp[v][0] += max(dp[to][0], dp[to][1]); dp[v][1] += dp[to][0]; } } void test() { cin >> n >> m; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> a[i][j]; } } for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(a[i][j] == 'G' && a[i][j - 1] == 'R' && a[i][j + 1] == 'W') { h[i][j - 1] = it++; } if(a[i][j] == 'G' && a[i - 1][j] == 'R' && a[i + 1][j] == 'W') { v[i - 1][j] = it++; } } } for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(a[i][j] == 'G' && a[i][j - 1] == 'R' && a[i][j + 1] == 'W') { if(v[i][j - 1]) { add(v[i][j - 1], h[i][j - 1]); } if(v[i - 1][j]) { add(v[i - 1][j], h[i][j - 1]); } if(v[i - 2][j + 1]) { add(v[i - 2][j + 1], h[i][j - 1]); } } if(a[i][j] == 'G' && a[i - 1][j] == 'R' && a[i + 1][j] == 'W') { if(h[i - 1][j]) { add(v[i - 1][j], h[i - 1][j]); } if(h[i][j - 1]) { add(v[i - 1][j], h[i][j - 1]); } if(h[i + 1][j - 2]) { add(v[i - 1][j], h[i + 1][j - 2]); } } } } for(int i = 1; i < it; i++) { sort(g[i].begin(), g[i].end()); g[i].resize(unique(g[i].begin(), g[i].end()) - g[i].begin()); } for(int i = 1; i < it; i++) { if(!vis[i]) { dfs(i); res += max(dp[i][0], dp[i][1]); } } cout << res << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; // cin >> t; while(t--) test(); return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'void dfs(int, int)':
dango_maker.cpp:19:10: error: invalid types 'int[int]' for array subscript
   19 |     dp[v][1] = 1;
      |          ^
dango_maker.cpp:23:14: error: invalid types 'int[int]' for array subscript
   23 |         dp[v][0] += max(dp[to][0], dp[to][1]);
      |              ^
dango_maker.cpp:23:31: error: invalid types 'int[int]' for array subscript
   23 |         dp[v][0] += max(dp[to][0], dp[to][1]);
      |                               ^
dango_maker.cpp:23:42: error: invalid types 'int[int]' for array subscript
   23 |         dp[v][0] += max(dp[to][0], dp[to][1]);
      |                                          ^
dango_maker.cpp:24:14: error: invalid types 'int[int]' for array subscript
   24 |         dp[v][1] += dp[to][0];
      |              ^
dango_maker.cpp:24:27: error: invalid types 'int[int]' for array subscript
   24 |         dp[v][1] += dp[to][0];
      |                           ^
dango_maker.cpp: In function 'void test()':
dango_maker.cpp:77:29: error: invalid types 'int[int]' for array subscript
   77 |             res += max(dp[i][0], dp[i][1]);
      |                             ^
dango_maker.cpp:77:39: error: invalid types 'int[int]' for array subscript
   77 |             res += max(dp[i][0], dp[i][1]);
      |                                       ^