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的挂了..脑子里还有自己要挂的感觉,果然回头 ...
随机推荐
- 【学习笔记】动态规划—各种 DP 优化
[学习笔记]动态规划-各种 DP 优化 [大前言] 个人认为贪心,\(dp\) 是最难的,每次遇到题完全不知道该怎么办,看了题解后又瞬间恍然大悟(TAT).这篇文章也是花了我差不多一个月时间才全部完成 ...
- nodejs通过钉钉群机器人推送消息
nodejs 通过钉钉群机器人推送消息 Intro 最近在用 nodejs 写爬虫,之前的 nodejs 爬虫代码用 js 写的,感觉可维护性太差,也没有智能提示,于是把js改用ts(typescri ...
- Java开发桌面程序学习(二)————fxml布局与控件学习
JavaFx项目 新建完项目,我们的项目有三个文件 Main.java 程序入口类,载入界面并显示 Controller.java 事件处理,与fxml绑定 Sample.fxml 界面 sample ...
- SQL SERVER 数据库授权指定用户
在查询分析器下运行以下语句即可: GO USE [master] GO ALTER AUTHORIZATION ON DATABASE::[数据库名] TO [用户名] GO
- python基础(18):初识模块、re模块
1. 认识模块 常见的场景:一个模块就是一个包含了python定义和声明的文件,文件名就是模块名字加上.py的后缀. 但其实import加载的模块分为四个通用类别: 1.使用python编写的代码(. ...
- 关于es6及以上的js编译成es5
问题:es6及以上版本在IE浏览器上不能执行起来,但Chrome浏览器上轻松运行,解决兼容IE的问题就需要使用babel:这个可以去babel的官网去查看; 关于babel的简单使用,有两种方式: 1 ...
- Unity API学习笔记(1)
首先创建测试项目: 这里我选择了2D,其实都可以,之后可以在项目中修改. 修改方法: 进入正题. 首先看一下官方提供的>手册和>脚本API文档. 创建C#脚本文件并打开: 默认的脚本文件为 ...
- NumPy实现数组的拼接和分裂
一.数组的拼接 import numpy as np x=np.array([,,]) x2=np.array([,,])np.concatenate([x,x2]) 输出:array([1, 2, ...
- Python—文件读写操作
初识文件操作 使用open()函数打开一个文件,获取到文件句柄,然后通过文件句柄就可以进行各种各样的操作了,根据打开文件的方式不同能够执行的操作也会有相应的差异. 打开文件的方式: r, w, a, ...
- K60时钟分析
转载:https://blog.csdn.net/hcx25909/article/details/7164650 1.飞思卡尔K60时钟系统 飞思卡尔K60时钟系统如上图所示,可以 ...