Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为啥会运行错误呢???

Posted by chenguanjun at 2011-08-19 18:23:23 on Problem 3636
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct Point {
    int x;
    int y;
}point[2005];
int vist[2005];
int cmp(Point a,Point b)
{
    if(a.x==b.x) return a.y<b.y;
    return a.x<b.x;
}
int main()
{
    int t,m;
    cin>>t;
    while(t--){
        int i,j,num,k;
        cin>>m;
        for(i=0;i<m;i++)
         cin>>point[i].x>>point[i].y;
        sort(point,point+m,cmp);
        memset(vist,0,sizeof(vist));
        k=0;num=0;
        while(k<m){
            j=k;
            vist[k]=1;
            for(i=j+1;i<m;i++){
                if((!vist[i])&&point[i].x>point[j].x&&point[i].y>point[j].y){
                    j=i;
                    vist[i]=1;
                }
            }
            num++;
            while(vist[k]&&k<m)
             k++;
        }
        cout<<num<<endl;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator