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 |
大家帮着看看哪里错了》》样例过了。。#include <iostream> #include <algorithm> using namespace std; #define T 10000 int sto[T+10]={0}; struct str { int w; int l; int vis; }wood[T+10]; bool cmp(str a,str b) { if(a.w!=b.w) return (a.w<b.w); else return (a.l<b.l); } void find(int i,int n) { for(int j=i+1;j<n;j++) { if(wood[j].vis) continue; else if(wood[i].l<=wood[j].l) wood[j].vis=1; } return; } int arrange() { int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d%d",&wood[i].w,&wood[i].l); wood[i].vis=0; } sort(wood,wood+n,cmp); #ifdef DEBUG for(int i=0;i<n;i++) printf("%d %d %d\n",i+1,wood[i].w,wood[i].l); #endif int s=0; for(int i=0;i<n;i++) { if(wood[i].vis) { #ifdef DEBUG printf("!%d\n",i+1); #endif continue; } find(i,n); s++; } return s; } main() { int m; scanf("%d",&m); for(int i=1;i<=m;i++) sto[i]=arrange(); for(int i=1;i<=m;i++) printf("%d\n",sto[i]); system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator