Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 4ms
Memory: 1120kB
Author: CT12813031281
In contest: 1281

#include<stdio.h>
int main(){
	int n,l[1000][2],i,j,temp,k,p,flag;
	scanf("%d",&n);
	k=0;
	p=0;
	flag=1;
	for(i=0;i<n;i++){
		for(j=0;j<2;j++)
			scanf("%d",&l[i][j]);
		if(l[i][0]<l[i][1]){
			temp=l[i][0];
			l[i][0]=l[i][1];
			l[i][1]=temp;
		}
	}
	while(flag){
		for(i=p;i<n;i++){
			if(l[p][0]>=l[i+1][0]&&l[p][1]>=l[i+1][1]&&l[i+1][0]>0&&l[i+1][1]>0){
				l[p][0]=l[p][1]=0;
				p=i+1;
			}
			
		}
		l[p][0]=l[p][1]=0;
		k=k+1;
		flag=0;
		for(i=0;i<n;i++){
			if(l[i][0]!=0){
				flag=1;
				p=i;
				break;
			}
		}
	}
	printf("%d",k);
}