# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824608 | Amylopectin | Sandcastle 2 (JOI22_ho_t5) | C++14 | 5077 ms | 1364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const long long mxn = 1e6 + 10;
struct we
{
long long nn,mm,val;
};
bool cmp(const struct we &l,const struct we &r)
{
return l.val < r.val;
}
struct we poi[mxn] = {};
long long ta[mxn] = {};
long long ab(long long l)
{
if(l < 0)
{
return -l;
}
return l;
}
int main()
{
long long i,j,n,m,r,cn,cm,fn,fm,k,o,p,h,q,be,csu = 0,rn,rm,of;
scanf("%lld %lld",&n,&m);
r = n*m;
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
cn = i*m + j;
scanf("%lld",&poi[cn].val);
poi[cn].nn = i;
poi[cn].mm = j;
}
}
sort(poi,poi+r,cmp);
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
for(k=i; k<n; k++)
{
for(o=j; o<m; o++)
{
rn = -1;
rm = -1;
of = 0;
for(h=0; h<r; h++)
{
cn = poi[h].nn;
cm = poi[h].mm;
if(cn >= i && cn <= k && cm >= j && cm <= o)
{
if(rn == -1)
{
rn = cn;
rm = cm;
}
else
{
if(ab(cn - rn) + ab(cm - rm) > 1)
{
of = 1;
break;
}
rn = cn;
rm = cm;
}
}
}
if(of == 0)
{
csu ++;
// printf("%d %d %d %d\n",i,j,k,o);
}
}
}
}
}
printf("%lld\n",csu);
}
Compilation message (stderr)
# | 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... |