CF877C.Slava and tanks
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map.
Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Slava doesn't know the number of tanks and their positions, because he flies very high, but he can drop a bomb in any cell. All tanks in this cell will be damaged.
If a tank takes damage for the first time, it instantly moves to one of the neighboring cells (a tank in the cell n can only move to the cell n - 1, a tank in the cell 1 can only move to the cell 2). If a tank takes damage for the second time, it's counted as destroyed and never moves again. The tanks move only when they are damaged for the first time, they do not move by themselves.
Help Slava to destroy all tanks using as few bombs as possible.
斯拉瓦正在玩他最喜欢的游戏“和平闪电”。现在,他正驾驶一架轰炸机在一张非常特殊的地图上飞行。
形式化地说,这张地图是一张 1×n 的方格图,其方格从 1 编号到 n;每个方格中可能有一辆或多辆坦克。由于斯拉瓦飞得很高,他并不知道坦克的数量及其具体位置,但他可以在任意一个方格中投下一枚炸弹,该方格内的所有坦克都会受到伤害。
- 若一辆坦克首次受到伤害,它会立即移动到一个相邻的方格(位于方格 n 的坦克只能移向方格 n−1,位于方格 1 的坦克只能移向方格 2);
- 若一辆坦克第二次受到伤害,则视为被摧毁,此后不再移动。
坦克仅在首次受伤害时移动,不会自主移动。
请帮助斯拉瓦用尽可能少的炸弹摧毁所有坦克。
输入格式
The first line contains a single integer n (2 ≤ n ≤ 100 000) — the size of the map.
第一行包含一个整数 n(2≤n≤100000)——地图的大小。
输出格式
In the first line print m — the minimum number of bombs Slava needs to destroy all tanks.
In the second line print m integers _k_1, _k_2, ..., k__m. The number k__i means that the i-th bomb should be dropped at the cell k__i.
If there are multiple answers, you can print any of them.
第一行输出 m —— Slava 摧毁所有坦克所需的最少炸弹数量。
第二行输出 m 个整数 k1,k2,...,km。其中,数字 ki 表示第 i 颗炸弹应投放在单元格 ki 上。
若存在多个答案,输出任意一个即可。
输入输出样例
输入#1
2
输出#1
3 2 1 2
输入#2
3
输出#2
4 2 1 3 2
输入解题思路,AI测评打分。不知道怎么写?