CF2145B.Deck of Cards

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Monocarp has a deck of cards numbered from 11 to nn. Initially, the cards are arranged from smallest to largest, with 11 on top and nn at the bottom.

Monocarp performed kk actions on the deck. Each action was one of three types:

  • remove the top card;
  • remove the bottom card;
  • remove either the top or bottom card.

Your task is to determine the fate of each card: whether it remains in the deck, has been removed, or might be both.

Monocarp 有一副编号为 11 到 nn 的牌。初始时,这些牌按从小到大的顺序排列,11 在最上方,nn 在最下方。

Monocarp 对这副牌执行了 kk 次操作。每次操作是以下三种类型之一:

  • 移除最上方的牌;
  • 移除最下方的牌;
  • 移除最上方或最下方的牌(即:移除顶部或底部的牌,具体是哪一个不确定)。

你的任务是确定每张牌的命运:它是否仍留在牌堆中、是否已被移除,或者两种情况均有可能。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains two integers nn and kk (1≤k≤n≤2⋅1051 \le k \le n \le 2 \cdot 10^5).

The second line contains a string ss of length kk, consisting of characters 0, 1, and/or {2}. This string describes Monocarp's actions. If the ii-th character is 0, Monocarp removes the top card on the ii-th action. If it's 1, he removes the bottom card. If it's 2, either the top or bottom card can be removed.

Additional constraint on the input: the sum of nn over all test cases doesn't exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4),表示测试用例的数量。

每个测试用例的第一行包含两个整数 nn 和 kk(1≤k≤n≤2⋅1051 \le k \le n \le 2 \cdot 10^5)。

每个测试用例的第二行包含一个长度为 kk 的字符串 ss,由字符 0、1 和/或 2 组成。该字符串描述了 Monocarp 的操作:若第 ii 个字符为 0,则 Monocarp 在第 ii 次操作中移除最上面的牌;若为 1,则移除最下面的牌;若为 2,则可任选移除最上面或最下面的牌。

输入的额外约束:所有测试用例的 nn 值之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, print a string consisting of nn characters. The ii-th character should be + (plus sign) if the ii-th card is still in the deck, - (minus sign) if it has been removed, or ? (question mark) if its state is unknown.

对于每个测试用例,输出一个由 nn 个字符组成的字符串。其中第 ii 个字符应为 +(加号),表示第 ii 张牌仍在牌堆中;为 -(减号),表示该牌已被移除;或为 ?(问号),表示其状态未知。

输入输出样例

  • 输入#1

    4
    4 2
    01
    3 2
    22
    1 1
    2
    7 5
    01201

    输出#1

    -++-
    ???
    -
    --?+?--

输入解题思路,AI测评打分。不知道怎么写?

首页