Submission #624778

#TimeUsernameProblemLanguageResultExecution timeMemory
624778QwertyPiSandcastle 2 (JOI22_ho_t5)C++14
10 / 100
5025 ms6432 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int a[50013]; int h, w; int id(int i, int j){ return i * w + j; } int32_t main(){ cin >> h >> w; for(int i = 0; i < h * w; i++){ cin >> a[i]; } { set<int> S; map<int, int> M; for(int i = 0; i < h * w; i++){ S.insert(a[i]); } int idx = 0; for(auto j : S){ M[j] = idx++; } for(int i = 0; i < h * w; i++){ a[i] = M[a[i]]; } } int ans = 0; for(int u = 0; u < h; u++){ for(int b = u; b < h; b++){ for(int l = 0; l < w; l++){ for(int r = l; r < w; r++){ int x = u, y = l; int cnt = 1; for(int i = u; i <= b; i++){ for(int j = l; j <= r; j++){ if(a[id(i, j)] > a[id(x, y)]) x = i, y = j; } } while(cnt != (u - b + 1) * (r - l + 1)){ int nx = -1, ny = -1; for(auto dir : vector<pair<int, int>> {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}){ int rx = x + dir.first, ry = y + dir.second; if(rx > b || rx < u || ry > r || ry < l || a[id(rx, ry)] > a[id(x, y)]) continue; if(nx == -1 || a[id(nx, ny)] < a[id(rx, ry)]) nx = rx, ny = ry; } if(nx == -1) break; x = nx, y = ny; cnt++; } if(cnt == (b - u + 1) * (r - l + 1)){ ans++; } } } } } cout << ans << endl; }
#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...