A9109 | More Reclamation
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land.
The river area can be represented by a grid with $r$ rows and exactly two columns — each cell represents a rectangular area. The rows are numbered $1$ through $r$ from top to bottom, while the columns are numbered $1$ and $2$ .
Initially, all of the cells are occupied by the river. The plan is to turn some of those cells into land one by one, with the cities alternately choosing a cell to reclaim, and continuing until no more cells can be reclaimed.
However, the river is also used as a major trade route. The cities need to make sure that ships will still be able to sail from one end of the river to the other. More formally, if a cell $(r,c)$ has been reclaimed, it is not allowed to reclaim any of the cells $(r-1,3-c)$ , $(r,3-c)$ , or $(r+1,3-c)$ .
The cities are not on friendly terms, and each city wants to be the last city to reclaim a cell (they don't care about how many cells they reclaim, just who reclaims a cell last). The cities have already reclaimed $n$ cells. Your job is to determine which city will be the last to reclaim a cell, assuming both choose cells optimally from current moment.
The river area can be represented by a grid with $r$ rows and exactly two columns — each cell represents a rectangular area. The rows are numbered $1$ through $r$ from top to bottom, while the columns are numbered $1$ and $2$ .
Initially, all of the cells are occupied by the river. The plan is to turn some of those cells into land one by one, with the cities alternately choosing a cell to reclaim, and continuing until no more cells can be reclaimed.
However, the river is also used as a major trade route. The cities need to make sure that ships will still be able to sail from one end of the river to the other. More formally, if a cell $(r,c)$ has been reclaimed, it is not allowed to reclaim any of the cells $(r-1,3-c)$ , $(r,3-c)$ , or $(r+1,3-c)$ .
The cities are not on friendly terms, and each city wants to be the last city to reclaim a cell (they don't care about how many cells they reclaim, just who reclaims a cell last). The cities have already reclaimed $n$ cells. Your job is to determine which city will be the last to reclaim a cell, assuming both choose cells optimally from current moment.
输入格式
The first line consists of two integers $r$ and $n$ ( $1<=r<=100,0<=n<=r$ ). Then $n$ lines follow, describing the cells that were already reclaimed. Each line consists of two integers: $r_{i}$ and $c_{i}$ ( $1<=r_{i}<=r,1<=c_{i}<=2$ ), which represent the cell located at row $r_{i}$ and column $c_{i}$ . All of the lines describing the cells will be distinct, and the reclaimed cells will not violate the constraints above.
输出格式
Output "WIN" if the city whose turn it is to choose a cell can guarantee that they will be the last to choose a cell. Otherwise print "LOSE".
输入输出样例
输入 #1
3 1 1 1
输出 #1
WIN
输入 #2
12 2 4 1 8 1
输出 #2
WIN
输入 #3
1 1 1 2
输出 #3
LOSE
In the first example, there are 3 possible cells for the first city to reclaim: $(2,1)$ , $(3,1)$ , or $(3,2)$ . The first two possibilities both lose, as they leave exactly one cell for the other city.
However, reclaiming the cell at $(3,2)$ leaves no more cells that can be reclaimed, and therefore the first city wins.
In the third example, there are no cells that can be reclaimed.
However, reclaiming the cell at $(3,2)$ leaves no more cells that can be reclaimed, and therefore the first city wins.
In the third example, there are no cells that can be reclaimed.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted