CodeForce 176C Playing with Superglue
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player aims to stop the first one with a tube of superglue.
We'll describe the rules of the game in more detail.
The players move in turns. The first player begins.
With every move the first player chooses one of his unglued chips, and shifts it one square to the left, to the right, up or down. It is not allowed to move a chip beyond the board edge. At the beginning of a turn some squares of the board may be covered with a glue. The first player can move the chip to such square, in this case the chip gets tightly glued and cannot move any longer.
At each move the second player selects one of the free squares (which do not contain a chip or a glue) and covers it with superglue. The glue dries long and squares covered with it remain sticky up to the end of the game.
If, after some move of the first player both chips are in the same square, then the first player wins. If the first player cannot make a move (both of his chips are glued), then the second player wins. Note that the situation where the second player cannot make a move is impossible — he can always spread the glue on the square from which the first player has just moved the chip.
We will further clarify the case where both chips are glued and are in the same square. In this case the first player wins as the game ends as soon as both chips are in the same square, and the condition of the loss (the inability to move) does not arise.
You know the board sizes and the positions of the two chips on it. At the beginning of the game all board squares are glue-free. Find out who wins if the players play optimally.
The first line contains six integers n, m, x1, y1, x2, y2 — the board sizes and the coordinates of the first and second chips, correspondingly (1 ≤ n, m ≤ 100; 2 ≤ n × m; 1 ≤ x1, x2 ≤ n; 1 ≤ y1, y2 ≤ m). The numbers in the line are separated by single spaces.
It is guaranteed that the chips are located in different squares.
Output
If the first player wins, print "First" without the quotes. Otherwise, print "Second" without the quotes.
Examples
1 6 1 2 1 6
First
6 5 4 3 2 1
First
10 10 1 1 10 10
Second
OJ-ID:
CodeForce 176C
author:
Caution_X
date of submission:
20191012
tags:
easy problem
description modelling:
给定一个棋盘,两个棋子,双方轮流操作,A先走,每次移动一个棋子在相邻格子一格,B后走,每次可以在一个格子涂胶水,如果两个棋子可以重合,A赢,否则B赢
major steps to solve it:
1.如果棋盘“非常大”,可以猜想B一定会赢
2.此时我们讨论A赢得极限情况。
设开始时两个棋子分别在棋盘左上角和右下角,棋盘规模为:
1×5
2×5
3×5
4×4
时A恰好赢,其他情况下A都无法赢
AC code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,x1,x2,y1,y2;
scanf("%d%d%d%d%d%d",&n,&m,&x1,&y1,&x2,&y2);
int dmin,dmax;
dmin=min(abs(x1-x2),abs(y1-y2));
dmax=max(abs(x1-x2),abs(y1-y2));
if((dmin==&&dmax<=)||(dmin==&&dmax<=)||(dmin==&&dmax<=)||(dmin==&&dmax<=)) printf("First\n");
else printf("Second\n");
return ;
}
CodeForce 176C Playing with Superglue的更多相关文章
- CodeForces 176C Playing with Superglue 博弈论
Playing with Superglue 题目连接: http://codeforces.com/problemset/problem/176/C Description Two players ...
- (转) Playing FPS games with deep reinforcement learning
Playing FPS games with deep reinforcement learning 博文转自:https://blog.acolyer.org/2016/11/23/playing- ...
- Codeforce 546D
Soldier and Number Game Time Limit:3000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- Codeforce - Street Lamps
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...
- Codeforce 567D
One-Dimensional Battle Ships time limit per test 1 second memory limit per test 256 megabytes input ...
- (转) Deep Reinforcement Learning: Playing a Racing Game
Byte Tank Posts Archive Deep Reinforcement Learning: Playing a Racing Game OCT 6TH, 2016 Agent playi ...
- Codeforces Round #184 (Div. 2) E. Playing with String(博弈)
题目大意 两个人轮流在一个字符串上删掉一个字符,没有字符可删的人输掉游戏 删字符的规则如下: 1. 每次从一个字符串中选取一个字符,它是一个长度至少为 3 的奇回文串的中心 2. 删掉该字符,同时,他 ...
- ifrog-1028 Bob and Alice are playing numbers(trie树)
题目链接: Bob and Alice are playing numbers DESCRIPTION Bob and his girl friend are playing game togethe ...
- Codeforce Round #216 Div2
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...
随机推荐
- 在新的电脑上的Git本地库 与远程库关联前的一些设置
由于你的本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以,需要一点设置: 第1步:创建SSH Key.在用户主目录下(user/...),看看有没有.ssh目录,如果有,再看看这个目 ...
- 全网趣味网站分享:今日热榜/Pixiv高级搜索/win10激活工具/songtaste复活/sharesome汤不热替代者
1.回形针手册 由科普类视频节目“回形针PaperClip”近期提出的一个实用百科工具计划,计划名称是回形针手册. 包含了当下科技,农业等等各行各业的各种相关信息,计划刚刚开始! 关于回形针手册的详细 ...
- sql 小全
前些日子sql用到哪里写到哪里,乱七八糟,今天整理了一下,以作备份(虽然开通博客已经八个月了,但是今天还是第一次发表博文,好紧张啊~~) --2014.08.27号整理sql语句 1:进入数据库 us ...
- django实现客户端文件下载
基于django项目,由于不是专门讲文件的下载,这里仅是项目需要,所以可能不是特别的详细.仅做流程的演示: 实现过程: 1.准备下载url # 下载文件 url(r'^download_file/$' ...
- JavaWeb之servlet(1)
servlet servlet:就是一个Java程序,运行在web服务器中,用于接收和响应客户端的http请求.更多是配合动态资源使用.当然静态资源也要使用servlet,只不过Tomcat里面已经定 ...
- GBT22239-2008-等保1.0三级要求
第三级基本要求 7.1 技术要求 7.1.1 物理安全 7.1.1.1 物理位置的选择(G3) 本项要求包括: a) 机房和办公场地应选择在具有防震.防风和防雨等能力的建筑内: b) 机房场地 ...
- Python—路由追踪(并生成追踪图片)
需要先安装两个包 [root@localhost ~]# yum install graphviz // 为了使用dot命令 [root@localhost ~]# yum install Image ...
- python 指定字符串位置查找
指定字符串位置查找 #指定字符查找 s = 'F:/my_pycharm/pycharm_project/CSV表格/10.csv' print(s.find('/')) # 2, 第一个/在2位置 ...
- Shell命令-搜索文件或目录之which、find
文件及内容处理 - which.find 1. which:查找二进制命令,按环境变量PATH路径查找 which命令的功能说明 which 命令用于查找文件.which 指令会在环境变量 $PATH ...
- 2019 Multi-University Training Contest 1 String(序列自动机+贪心)
题意 链接:https://vjudge.net/problem/HDU-6586 给你一个字符串和k,还有每个字符出现次数的限制,求一个长度为k的字典序最小的满足限制的子序列. 思路 先构造出序列自 ...