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 |
why wa????????????#include<iostream> using namespace std; int a[102][102]; int n,k,t,maxx,co; struct p{ int x; int y; }p1,p2; void input() { int i; maxx=0; while(n--) { cin>>p1.x>>p1.y>>p2.x>>p2.y; int min=(p1.x<p2.x)?p1.x:p2.x; int max=(p1.x>p2.x)?p1.x:p2.x; if(maxx<max) maxx=max; for(i=min;i<=max;i++) a[p1.y][i]=max+1; } } void solve() { int i,j,count=0; for(i=0;i<maxx;i++) { int c=0; for(j=0;j<co;j++) if(a[j][i]!=0) c++; if(c>k) { count++; //searchmaxwall(); int e=i,len=0,wallmax=0,dewall,d; for(d=0;d<co;d++) { int m=a[d][i]; while(a[d][e]!=0&&a[d][e]==m) { e++; len++; } if(len>wallmax) { wallmax=len; dewall=d; } } for(e=i;e<i+wallmax;e++)//dellwall { a[dewall][e]=0; } } } cout<<count<<endl; } int main() { cin>>t; while(t--) { memset(a,0,sizeof(a)); cin>>n>>k; co=n; input(); solve(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator