#include<bits/stdc++.h>
using namespace std;
long long i,j,k,l,m,n,dp[1009][1009],a[1009][1009],x,y,x2,y2,jog,yok,as,s,c;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1; i<=n; i++){cin>>x>>y; a[x][y]=1; x2=max(x2,x); y2=max(y,y2);}
for(int i=0; i<=x2; i++)
{
for(int j=0; j<=y2; j++)
{
if(a[i][j]==0) continue;
yok=0; s=0; as=0; c=0;
for(int k=i-1; k>=0; k--)
{
if(a[k][j]==0) break; else yok++;
}
for(int k=i+1; k<=x2; k++)
{
if(a[k][j]==0) break; else as++;
}
for(int k=j-1; k>=0; k--)
{
if(a[i][k]==0) break; else c++;
}
for(int k=j+1; k<=y2; k++)
{
if(a[i][k]==0) break; else s++;
}
jog+=(yok*c)+(yok*s)+(s*as)+(as*c);
}
}
cout<<jog;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
18084 KB |
Output is correct |
2 |
Correct |
0 ms |
18084 KB |
Output is correct |
3 |
Incorrect |
0 ms |
18084 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |