Submission #282978

#TimeUsernameProblemLanguageResultExecution timeMemory
282978lani1akeaT-Covering (eJOI19_covering)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define F first #define S second #define ll long long #define pb push_back #define endl '\n' using namespace std; const int MOD = 1e9+7; const int N = 1e3; int n, m, k, g[N][N], x[N * 1000], y[N * 1000], ans = -1; void dfs(int nu, int used[N][N], int p) { if (nu == k) { ans = max(ans, p); return; } if (used[x[nu]][y[nu]) { return; } if (x[nu] < n - 1 and y[nu] < m - 1 and y[nu] and !used[x[nu]][y[nu]] and !used[x[nu]][y[nu] - 1] and !used[x[nu]][y[nu] + 1] and !used[x[nu] + 1][y[nu]]) { // down used[x[nu]][y[nu]] = used[x[nu]][y[nu] - 1] = used[x[nu]][y[nu] + 1] = used[x[nu] + 1][y[nu]] = 1; p += g[x[nu]][y[nu]]; p += g[x[nu]][y[nu] - 1]; p += g[x[nu]][y[nu] + 1]; p += g[x[nu] + 1][y[nu]]; dfs(nu + 1, used, p); used[x[nu]][y[nu]] = used[x[nu]][y[nu] - 1] = used[x[nu]][y[nu] + 1] = used[x[nu] + 1][y[nu]] = 0; p -= g[x[nu]][y[nu]]; p -= g[x[nu]][y[nu] - 1]; p -= g[x[nu]][y[nu] + 1]; p -= g[x[nu] + 1][y[nu]]; } if (x[nu] and y[nu] < m - 1 and y[nu] and !used[x[nu]][y[nu]] and !used[x[nu]][y[nu] - 1] and !used[x[nu]][y[nu] + 1] and !used[x[nu] - 1][y[nu]]) { // up used[x[nu]][y[nu]] = used[x[nu]][y[nu] - 1] = used[x[nu]][y[nu] + 1] = used[x[nu] - 1][y[nu]] = 1; p += g[x[nu]][y[nu]]; p += g[x[nu]][y[nu] - 1]; p += g[x[nu]][y[nu] + 1]; p += g[x[nu] - 1][y[nu]]; dfs(nu + 1, used, p); used[x[nu]][y[nu]] = used[x[nu]][y[nu] - 1] = used[x[nu]][y[nu] + 1] = used[x[nu] - 1][y[nu]] = 0; p -= g[x[nu]][y[nu]]; p -= g[x[nu]][y[nu] - 1]; p -= g[x[nu]][y[nu] + 1]; p -= g[x[nu] - 1][y[nu]]; } if (x[nu] < n - 1 and x[nu] and y[nu] and !used[x[nu]][y[nu]] and !used[x[nu]][y[nu] - 1] and !used[x[nu] + 1][y[nu]] and !used[x[nu] - 1][y[nu]]) { // left used[x[nu]][y[nu]] = used[x[nu]][y[nu] - 1] = used[x[nu] + 1][y[nu]] = used[x[nu] - 1][y[nu]] = 1; p += g[x[nu]][y[nu]]; p += g[x[nu]][y[nu] - 1]; p += g[x[nu] + 1][y[nu]]; p += g[x[nu] - 1][y[nu]]; dfs(nu + 1, used, p); used[x[nu]][y[nu]] = used[x[nu]][y[nu] - 1] = used[x[nu] + 1][y[nu]] = used[x[nu] - 1][y[nu]] = 0; p -= g[x[nu]][y[nu]]; p -= g[x[nu]][y[nu] - 1]; p -= g[x[nu] + 1][y[nu]]; p -= g[x[nu] - 1][y[nu]]; } if (x[nu] < n - 1 and x[nu] and y[nu] < m - 1 and !used[x[nu]][y[nu]] and !used[x[nu]][y[nu] + 1] and !used[x[nu] + 1][y[nu]] and !used[x[nu] - 1][y[nu]]) { // right used[x[nu]][y[nu]] = used[x[nu]][y[nu] + 1] = used[x[nu] + 1][y[nu]] = used[x[nu] - 1][y[nu]] = 1; p += g[x[nu]][y[nu]]; p += g[x[nu]][y[nu] + 1]; p += g[x[nu] + 1][y[nu]]; p += g[x[nu] - 1][y[nu]]; dfs(nu + 1, used, p); used[x[nu]][y[nu]] = used[x[nu]][y[nu] + 1] = used[x[nu] + 1][y[nu]] = used[x[nu] - 1][y[nu]] = 0; p -= g[x[nu]][y[nu]]; p -= g[x[nu]][y[nu] + 1]; p -= g[x[nu] + 1][y[nu]]; p -= g[x[nu] - 1][y[nu]]; } return; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> g[i][j]; } } cin >> k; for (int i = 0; i < k; ++i) { cin >> x[i] >> y[i]; } int used[N][N]; dfs(0,used,0); if (ans == -1) cout << "No\n"; else cout << ans << endl; }

Compilation message (stderr)

covering.cpp: In function 'void dfs(int, int (*)[1000], int)':
covering.cpp:20:26: error: expected ']' before ')' token
   20 |     if (used[x[nu]][y[nu]) {
      |                          ^
      |                          ]