| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我的代码wrong answer!为什么呀?实在是找不出错啦!帮忙看看啊!!思路:将数据存在二维数组中,每次查找纵坐标比该坐标值大,横坐标比其小的,即右上角的;
#include<stdio.h>
#include<string.h>
__int64 c[1001][1001];
__int64 result;
__int64 kk;
int main()
{
int b,i,j,ii,p;
int n,m,k,x,y;
scanf("%d",&b);
for(ii=0;ii<b;ii++)
{
for(i=0;i<1001;i++)
{
for(j=0;j<1001;j++)
c[i][j]=0;
}
scanf("%d%d%d",&n,&m,&k);
result=0;
for(j=0;j<k;j++)
{
scanf("%d%d",&x,&y);
c[x][y]++;
}
result=0;
for(i=1;i<=n;i++)
{
kk=0;
for(j=m;j>0;j--)
{
if(c[i][j]>0)
{
result+=c[i-1][j]*c[i][j];
p=kk;
kk+=c[i][j];
c[i][j]=p+c[i-1][j];
}
else c[i][j]=kk+c[i-1][j];
}
}
printf("Text case %d: %I64d\n",ii+1,result);
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator