<center> 4078.   find the princessI
Time Limit: 1.0 Seconds    Memory Limit:65536K
Total Runs: 406    Accepted Runs:140 </center>


Nowadays, lots of students enjoy the cellphone game Kupao of Tencent. The story of Kupao is that goddess of Dsir was caught by an evil man and Dsir wants to rescue her of danger.
The operator of Kupao is jump or squat down. However, it is easier for Dsir. The rule is followed:
1: There is a map with two dimensional (x,y). Dsir is on (0,0) an the beginning and he should reach at (100,0) finally.
2: Every thing at the map with 1 length and 1 height include Dsir.
3: There are some blocks at the map and they can floating in the air, but Dsir can not get through.
It is that if there is a block at (1,0), Dsir can not pass without jump.
4: Dsir can only go forward or jump. Eg: if he jump at (0,0) the whole trace is(0,0)->(1,1)->(2,2)->(3,1)->(4,0) and when he jump any block at these place is forbidden.
More clearly see this picture.
5: some blocks may at same place!

<center> </center>

Input

A number N indicate the blocks number. N < 100;
Then N lines followed. Each line with two number (x,y) meanings the block’s place.
0 < x < 96 , 0 ≤ y < 3

Output

If Dsir can reach at (100,0) ouput 1, otherwise output 0.

Sample Input

3

1 0

1 1

1 2

3

2 0

2 1

5 1

Sample Output

0
1


只需要判断上边两个和下边两个是否联通 


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

int map[5][120];

int main()
{
	int N;
	while(scanf("%d",&N)!=EOF)
	{
		memset(map,0,sizeof(map));
		for(int i=0;i<N;i++)
		{
			int r,c;
			scanf("%d %d",&r,&c);
			map[c][r] = 1;
		}
		
		int flag = 1;
		for(int i = 1 ; i <= 100 ; i++)
		{
			//have block 
			if(map[0][i] == 1)
			{
				//先看是否在范围内
				if(i-1 >= 0 && i < 100 && i+1 < 100 && i+2 < 100 && i+3 <=100)
				{
					//再看是否有块
					if(map[0][i-1]==0 && map[1][i]==0 && map[2][i+1]==0 && map[1][i+2]==0 && map[0][i+3] ==0)
					{
						//能过
						continue; 
					}
				}
				
				if(i-2 >= 0 && i-1 < 100 && i < 100 && i+1 < 100 && i+2 <=100)
				{
					if(map[0][i-2]==0 && map[1][i-1]==0 && map[2][i]==0 && map[1][i+1]==0 && map[0][i+2] ==0)
					{
						//能过
						continue; 
					}	
				}
				
				if(i-3 >= 0 && i-2 < 100 && i-1 < 100 && i < 100 && i+1 <=100)
				{
					if(map[0][i-3]==0 && map[1][i-2]==0 && map[2][i-1]==0 && map[1][i]==0 && map[0][i+1] ==0)
					{
						//能过
						continue; 
					}	
				}  
				
				//过不了
				flag =0 ;
				break; 
			}
		}
		
		if(flag == 0)
			printf("0\n");
		else 
			printf("1\n");
		
		
	}
	return 0;
}