⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1756.cpp

📁 zju 1756,比较简单
💻 CPP
字号:
#include"iostream"
#include"stdio.h" 
#include"string"
#include"list"
using namespace std;
typedef struct data 
{
	int x,y;
	struct data *next;
}Robots;
 
void insert(Robots *f,Robots *t)
{
	Robots *q,*h;	 
		q=h=f;
		for(h=h->next;h;q=h,h=h->next)
		{
			if(h->x>t->x)	
			{
				q->next=t;
				t->next=h;
				break;
			}
			if(h->x==t->x&&h->y>t->y) 
			{
				q->next=t;
				t->next=h;
				break;
			}
			if((h->x==t->x)&&(h->y==t->y)){delete(t);break;}
		}
		if(h==0) q->next=t; 	
}
				
 main()
{
	Robots *f,*t,*p,*q;
	int x,y;
	int c=0;
	f=(Robots *)malloc(sizeof(struct data));
	f->next=0;
	 
	do{
		c=0;
		while(cin>>x>>y)
	{
		if((x==0)&&(y==0))break;
		if((x==-1)&&(y==-1))return 1;
		t=(Robots *)malloc(sizeof(struct data));
		t->next=0;
		t->x=x;
		t->y=y;
	    insert(f,t);
	} 
  
	while(f->next)
	{
		x=f->next->x;
		y=f->next->y;		 
		p=f->next;
		q=f;
		while(p)
		{
			if((p->x>=x)&&(p->y>=y))
			{   
				x=p->x;
			    y=p->y;
				q->next=p->next;
				delete(p);
				p=q->next;
			}               //delete p
			else
			{
				q=p;
				p=p->next;
			}
		}
		 
		c++;
	}            
	cout<<c<<endl;
	}while(1);
	return 1;
}        

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -