TOJ 4078 find the princessI(模拟)
来源:互联网 发布:淘宝清洗已过期 编辑:程序博客网 时间:2024/05/20 20:55
Time Limit: 1.0 Seconds Memory Limit:65536K
Total Runs: 406 Accepted Runs:140
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!
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
31 01 11 232 02 15 1
Sample Output
01
只需要判断上边两个和下边两个是否联通
#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;}
- TOJ 4078 find the princessI(模拟)
- TOJ 2429 Find the Clones
- TOJ 2968. Find the Diagonal
- TOJ 4115 Find the number
- TOJ 4079 find the princessII(简单博弈)
- TOJ 4080 find the princessIII(圆和直线相交)
- TOJ 4081 God Le wants to know the directory(模拟)
- 【HDU 1597】find the nth digit(模拟)
- hdu 1597 find the nth digit(模拟)
- ZOJ 3432 Find the Lost Sock(模拟)
- TOJ 1868.Count the factors(埃式筛法)
- TOJ 1301.The Trip(精度题)
- TOJ 3105.A Way To Find Primes(埃式筛法)
- HDU1597 find the nth digit【模拟】
- TOJ 1782.The jackpot
- TOJ 2917.The Watchman
- TOJ 3517 The longest athletic track(树直径)
- TOJ 4168 I-The brute force problem(数论)
- SQL 2008 R2 数据库操作,不允许保存更改。您所做的更改要求删除并重新创建一下表。您对无法重新创建的表进行了更改或启用了“阻止保存要求重新创建表的更改”选项
- 5.SpringAOP基础
- node.js ——centos爬坑node.js安装、全局环境配置、pm2安装
- java注解型 事务处理
- 绘制星号图----坐标分析法
- TOJ 4078 find the princessI(模拟)
- PHP常用函数有哪些?
- 调通全志R16平台的AP6212A0版本的BT(分色排版)V1.1版本
- cin.get()和cin.getline()之间的区别
- RabbitMQ(二) java简单的实现RabbitMQ
- 规律、等比数列、逆元
- hdu-4417-Super Mario(无修改的主席树-求小于等于k的个数)
- 大数据-执行start-dfs.sh后,datenode没有启动
- oracle 两个字符串根据指定分割符分割后比较方法