Submission #531718

#TimeUsernameProblemLanguageResultExecution timeMemory
531718errorgornSandcastle 2 (JOI22_ho_t5)C++17
15 / 100
5042 ms1048580 KiB
#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 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...