Submission #704439

#TimeUsernameProblemLanguageResultExecution timeMemory
704439ld_minh4354Sandcastle 2 (JOI22_ho_t5)C++17
10 / 100
5071 ms18092 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define debug(x) cout<<#x<<": "<<x<<"\n" signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("input.000","r",stdin); // freopen("output.000","w",stdout); // srand((unsigned)time(NULL)); // rand() int n,i,a[1505][1505],j,m,c,ans,l,r,u,d; pair<int,pair<int,int>> p[1505]; bool tr; cin>>n>>m; for (i=1;i<n+1;i++) for (j=1;j<m+1;j++) cin>>a[i][j]; ans=0; for (u=1;u<n+1;u++) for (d=u;d<n+1;d++) for (l=1;l<m+1;l++) for (r=l;r<m+1;r++) { c=0;tr=true; for (i=u;i<d+1;i++) for (j=l;j<r+1;j++) { c++; p[c]={a[i][j],{i,j}}; } sort(p+1,p+c+1); for (i=1;i<c;i++) if (abs(p[i].se.fi - p[i+1].se.fi) + abs(p[i].se.se - p[i+1].se.se) != 1) tr=false; if (tr) ans++; } cout<<ans; }
#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...