309852: CF1746A. Maxmina

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Maxmina

题意翻译

#### 题目描述 给定一个长度为 $n$ 的只包含 $0$ 和 $1$ 的序列 $a$ 和一个数字 $k$,可以进行如下的操作各若干次: - 选定一个 $i\in[1,n-1]$,将 $a_i$ 和 $a_{i+1}$ 这两个数替换为它们的最小值。进行此操作后,序列的长度 $n$ 减少 $1$。 - 选定一个 $i\in[1,n-k+1]$,将 $a_i$ 到 $a_{i+k-1}$ 这 $k$ 个数替换为它们的最大值。进行此操作后,序列的长度 $n$ 减少 $k-1$。 判断经过若干次操作后是否能使 $n=1$ 且 $a_1=1$。 #### 输入 $t$ 组数据,每组数据第一行输入两个整数 $n$ 和 $k$,第二行输入 $n$ 个整数 $a_i$。 #### 输出 若可以,输出 `YES`,否则输出 `NO`。

题目描述

You have an array $ a $ of size $ n $ consisting only of zeroes and ones and an integer $ k $ . In one operation you can do one of the following: - Select $ 2 $ consecutive elements of $ a $ and replace them with their minimum (that is, let $ a := [a_{1}, a_{2}, \ldots, a_{i-1}, \min(a_{i}, a_{i+1}), a_{i+2}, \ldots, a_{n}] $ for some $ 1 \le i \le n-1 $ ). This operation decreases the size of $ a $ by $ 1 $ . - Select $ k $ consecutive elements of $ a $ and replace them with their maximum (that is, let $ a := [a_{1}, a_{2}, \ldots, a_{i-1}, \max(a_{i}, a_{i+1}, \ldots, a_{i+k-1}), a_{i+k}, \ldots, a_{n}] $ for some $ 1 \le i \le n-k+1 $ ). This operation decreases the size of $ a $ by $ k-1 $ . Determine if it's possible to turn $ a $ into $ [1] $ after several (possibly zero) operations.

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 1000 $ ). The description of the test cases follows. The first line of each test case contains two integers $ n $ and $ k $ ( $ 2 \le k \le n \le 50 $ ), the size of array $ a $ and the length of segments that you can perform second type operation on. The second line contains $ n $ integers $ a_{1}, a_{2}, \ldots, a_{n} $ ( $ a_i $ is $ 0 $ or $ 1 $ ), elements of array $ a $ .

输出格式


For each test case, if it is possible to turn $ a $ into $ [1] $ , print "YES", otherwise print "NO".

输入输出样例

输入样例 #1

7
3 2
0 1 0
5 3
1 0 1 1 0
2 2
1 1
4 4
0 0 0 0
6 3
0 0 1 0 0 1
7 5
1 1 1 1 1 1 1
5 3
0 0 1 0 0

输出样例 #1

YES
YES
YES
NO
YES
YES
YES

说明

In the first test case, you can perform the second type operation on second and third elements so $ a $ becomes $ [0, 1] $ , then you can perform the second type operation on first and second elements, so $ a $ turns to $ [1] $ . In the fourth test case, it's obvious to see that you can't make any $ 1 $ , no matter what you do. In the fifth test case, you can first perform a type 2 operation on the first three elements so that $ a $ becomes $ [1, 0, 0, 1] $ , then perform a type 2 operation on the elements in positions two through four, so that $ a $ becomes $ [1, 1] $ , and finally perform the first type operation on the remaining elements, so that $ a $ becomes $ [1] $ .

Input

题意翻译

#### 题目描述 给定一个长度为 $n$ 的只包含 $0$ 和 $1$ 的序列 $a$ 和一个数字 $k$,可以进行如下的操作各若干次: - 选定一个 $i\in[1,n-1]$,将 $a_i$ 和 $a_{i+1}$ 这两个数替换为它们的最小值。进行此操作后,序列的长度 $n$ 减少 $1$。 - 选定一个 $i\in[1,n-k+1]$,将 $a_i$ 到 $a_{i+k-1}$ 这 $k$ 个数替换为它们的最大值。进行此操作后,序列的长度 $n$ 减少 $k-1$。 判断经过若干次操作后是否能使 $n=1$ 且 $a_1=1$。 #### 输入 $t$ 组数据,每组数据第一行输入两个整数 $n$ 和 $k$,第二行输入 $n$ 个整数 $a_i$。 #### 输出 若可以,输出 `YES`,否则输出 `NO`。

Output

**题意翻译**

题目描述

给定一个长度为 $ n $ 的只包含 $ 0 $ 和 $ 1 $ 的序列 $ a $ 和一个数字 $ k $,可以进行如下的操作各若干次:

- 选定一个 $ i \in [1, n-1] $,将 $ a_i $ 和 $ a_{i+1} $ 这两个数替换为它们的最小值。进行此操作后,序列的长度 $ n $ 减少 $ 1 $。

- 选定一个 $ i \in [1, n-k+1] $,将 $ a_i $ 到 $ a_{i+k-1} $ 这 $ k $ 个数替换为它们的最大值。进行此操作后,序列的长度 $ n $ 减少 $ k-1 $。

判断经过若干次操作后是否能使 $ n=1 $ 且 $ a_1=1 $。

输入

$ t $ 组数据,每组数据第一行输入两个整数 $ n $ 和 $ k $,第二行输入 $ n $ 个整数 $ a_i $。

输出

若可以,输出 `YES`,否则输出 `NO`。

**题目描述**

给定一个包含 $ n $ 个 0 和 1 的数组 $ a $ 和一个整数 $ k $。你可以进行以下操作:

- 选择 $ a $ 中的 2 个连续元素并将它们替换为它们的最小值(即,对于某个 $ 1 \le i \le n-1 $,让 $ a := [a_{1}, a_{2}, \ldots, a_{i-1}, \min(a_{i}, a_{i+1}), a_{i+2}, \ldots, a_{n}] $)。此操作将数组 $ a $ 的大小减少 1。

- 选择 $ k $ 个连续元素并将它们替换为它们的最大值(即,对于某个 $ 1 \le i \le n-k+1 $,让 $ a := [a_{1}, a_{2}, \ldots, a_{i-1}, \max(a_{i}, a_{i+1}, \ldots, a_{i+k-1}), a_{i+k}, \ldots, a_{n}] $)。此操作将数组 $ a $ 的大小减少 $ k-1 $。

判断是否可以通过若干次(可能为零)操作将 $ a $ 转换为 $ [1] $。

**输入输出格式**

输入格式

每个测试包含多个测试用例。第一行包含测试用例数 $ t $($ 1 \le t \le 1000 $)。接下来是每个测试用例的描述。

每个测试用例的第一行包含两个整数 $ n $ 和 $ k $($ 2 \le k \le n \le 50 $),分别是数组 $ a $ 的大小和你可以执行第二种操作的部分的长度。

第二行包含 $ n $ 个整数 $ a_{1}, a_{2}, \ldots, a_{n} $($ a_i $ 是 0 或 1),是数组 $ a $ 的元素。

输出格式

对于每个测试用例,如果可以将 $ a $ 转换为 $ [1] $,则打印 "YES",否则打印 "NO"。

**输入输出样例**

输入样例 #1

```
7
3 2
0 1 0
5 3
1 0 1 1 0
2 2
1 1
4 4
0 0 0 0
6 3
0 0 1 0 0 1
7 5
1 1 1 1 1 1 1
5 3
0 0 1 0 0
```

输出样例 #1

```
YES
YES
YES
NO
YES
YES
YES
```**题意翻译** 题目描述 给定一个长度为 $ n $ 的只包含 $ 0 $ 和 $ 1 $ 的序列 $ a $ 和一个数字 $ k $,可以进行如下的操作各若干次: - 选定一个 $ i \in [1, n-1] $,将 $ a_i $ 和 $ a_{i+1} $ 这两个数替换为它们的最小值。进行此操作后,序列的长度 $ n $ 减少 $ 1 $。 - 选定一个 $ i \in [1, n-k+1] $,将 $ a_i $ 到 $ a_{i+k-1} $ 这 $ k $ 个数替换为它们的最大值。进行此操作后,序列的长度 $ n $ 减少 $ k-1 $。 判断经过若干次操作后是否能使 $ n=1 $ 且 $ a_1=1 $。 输入 $ t $ 组数据,每组数据第一行输入两个整数 $ n $ 和 $ k $,第二行输入 $ n $ 个整数 $ a_i $。 输出 若可以,输出 `YES`,否则输出 `NO`。 **题目描述** 给定一个包含 $ n $ 个 0 和 1 的数组 $ a $ 和一个整数 $ k $。你可以进行以下操作: - 选择 $ a $ 中的 2 个连续元素并将它们替换为它们的最小值(即,对于某个 $ 1 \le i \le n-1 $,让 $ a := [a_{1}, a_{2}, \ldots, a_{i-1}, \min(a_{i}, a_{i+1}), a_{i+2}, \ldots, a_{n}] $)。此操作将数组 $ a $ 的大小减少 1。 - 选择 $ k $ 个连续元素并将它们替换为它们的最大值(即,对于某个 $ 1 \le i \le n-k+1 $,让 $ a := [a_{1}, a_{2}, \ldots, a_{i-1}, \max(a_{i}, a_{i+1}, \ldots, a_{i+k-1}), a_{i+k}, \ldots, a_{n}] $)。此操作将数组 $ a $ 的大小减少 $ k-1 $。 判断是否可以通过若干次(可能为零)操作将 $ a $ 转换为 $ [1] $。 **输入输出格式** 输入格式 每个测试包含多个测试用例。第一行包含测试用例数 $ t $($ 1 \le t \le 1000 $)。接下来是每个测试用例的描述。 每个测试用例的第一行包含两个整数 $ n $ 和 $ k $($ 2 \le k \le n \le 50 $),分别是数组 $ a $ 的大小和你可以执行第二种操作的部分的长度。 第二行包含 $ n $ 个整数 $ a_{1}, a_{2}, \ldots, a_{n} $($ a_i $ 是 0 或 1),是数组 $ a $ 的元素。 输出格式 对于每个测试用例,如果可以将 $ a $ 转换为 $ [1] $,则打印 "YES",否则打印 "NO"。 **输入输出样例** 输入样例 #1 ``` 7 3 2 0 1 0 5 3 1 0 1 1 0 2 2 1 1 4 4 0 0 0 0 6 3 0 0 1 0 0 1 7 5 1 1 1 1 1 1 1 5 3 0 0 1 0 0 ``` 输出样例 #1 ``` YES YES YES NO YES YES YES ```

加入题单

算法标签: