이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
int n,m;
int arr[1500][1500];
vector<ii> idx;
int dist(ii i,ii j){
return abs(i.fi-j.fi)+abs(i.se-j.se);
}
signed main(){
cin.tie(0);
cout.tie(0);
cin.sync_with_stdio(false);
cin>>n>>m;
rep(x,0,n) rep(y,0,m){
cin>>arr[x][y];
idx.pub({x,y});
}
sort(all(idx),[](ii i,ii j){
return arr[i.fi][i.se]<arr[j.fi][j.se];
});
int ans=0;
rep(x1,0,n) rep(x2,x1,n) rep(y1,0,m) rep(y2,y1,m){
ii p={-1,-1};
bool ok=true;
for (auto it:idx) if (x1<=it.fi && it.fi<=x2 && y1<=it.se && it.se<=y2){
if (p!=ii(-1,-1) && dist(it,p)>1){
ok=false;
break;
}
p=it;
}
if (ok) ans++;
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |