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 |
WA 了 哪位ac的给我出组数据? 感激~#include <string.h> #include<stdio.h> #include<iostream> #include<algorithm> using namespace std; int d1[26000010],d2[26000010]; int a[4010],b[4010],c[4010],d[4010]; int main() { int n; int ans=0; int i,j,k,l,p,q; scanf("%d",&n); { memset(d1,0,sizeof(d1)); memset(d2,0,sizeof(d2)); while(n>4000) printf("assadfasdfsdfsadfdf"); for(i=0;i<n;i++) scanf("%d%d%d%d",a+i,b+i,c+i,d+i); for(i=0;i<n;i++) { for(j=0;j<n;j++) { d1[i*n+j]=a[i]+b[j]; } } for(i=0;i<n;i++) { for(j=0;j<n;j++) { d2[i*n+j]=c[i]+d[j]; } } k=n*n; sort(d1,d1+k); sort(d2,d2+k); j=k-1; ans=0; for(i=0;i<k;i++) { while(j>=0 && d1[i]+d2[j]>0) j--; if(j<0) break; if(d1[i]+d2[j]==0) { p=q=0; l=d1[i]; while(i<k && l==d1[i]) { i++;p++; } l=d2[j]; while(j>=0 && l==d2[j] ) { j--;q++; } ans+=p*q; //ans++; } if(j<0) break; } printf("%d\n",ans); } for(;;) return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator