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 |
Help me! 还是在WA...In Reply To:间歇性的TLE->WA->TLE->WA...终于有了M*N的算法,但怎么会WA呢? Posted by:jiaohang at 2006-11-04 17:34:50 #include<stdio.h> #include<string.h> int main() { int TT; int n[1001],N,M,K; long long R; int c[1001][1001]; scanf("%d",&TT); for(int TTT=1;TTT<=TT;++TTT) { R=0; scanf("%d%d%d",&N,&M,&K); memset(n,0,sizeof(n)); memset(c,0,sizeof(c)); for(int i=0;i<K;++i) { int x,y; scanf("%d%d",&x,&y); c[x][y]++; } for(int x=1;x<=N;++x) { long long f=0; for(int y=1;y<=M;++y) { R+=f*n[y]; if(c[x][y]) { f+=c[x][y]; n[y]+=c[x][y]; } } } printf("Test case %d: %lld\n",TTT,R); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator