Submission #594171

#TimeUsernameProblemLanguageResultExecution timeMemory
594171piOOESandcastle 2 (JOI22_ho_t5)C++17
10 / 100
5092 ms1088 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; bool swapped = false; if (n > m) { swapped = true; swap(n, m); } vector<vector<int>> a(n, vector<int>(m)); for (int i = 0; i < (swapped ? m : n); ++i) { for (int j = 0; j < (swapped ? n : m); ++j) { if (!swapped) { cin >> a[i][j]; } else { cin >> a[j][i]; } } } int x1, y1, x2, y2; auto MIN = [&](int x, int y) -> bool { if (x > x1 && a[x - 1][y] < a[x][y]) return false; if (y > y1 && a[x][y - 1] < a[x][y]) return false; if (x < x2 && a[x + 1][y] < a[x][y]) return false; if (y < y2 && a[x][y + 1] < a[x][y]) return false; return true; }; auto MAX = [&](int x, int y) -> bool { if (x > x1 && a[x - 1][y] > a[x][y]) return false; if (y > y1 && a[x][y - 1] > a[x][y]) return false; if (x < x2 && a[x + 1][y] > a[x][y]) return false; if (y < y2 && a[x][y + 1] > a[x][y]) return false; return true; }; int ans = 0; for (x1 = 0; x1 < n; ++x1) { for (y1 = 0; y1 < m; ++y1) { for (x2 = x1; x2 < n; ++x2) { for (y2 = y1; y2 < m; ++y2) { int cnt = 0; vector<array<int, 3>> v; for (int i = x1; i <= x2 && cnt <= 2; ++i) { for (int j = y1; j <= y2 && cnt <= 2; ++j) { v.push_back({a[i][j], i, j}); } } sort(v.begin(), v.end()); bool ok = true; for (int i = 1; i < int(v.size()) && ok; ++i) { ok &= abs(v[i][1] - v[i - 1][1]) + abs(v[i][2] - v[i - 1][2]) <= 1; } if (ok) { ans += 1; } } } } } cout << ans; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:29:10: warning: variable 'MIN' set but not used [-Wunused-but-set-variable]
   29 |     auto MIN = [&](int x, int y) -> bool {
      |          ^~~
Main.cpp:37:10: warning: variable 'MAX' set but not used [-Wunused-but-set-variable]
   37 |     auto MAX = [&](int x, int y) -> bool {
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...