B. osu!mania

B. osu!mania

time limit per test

1 second

memory limit per test

256 megabytes

You are playing your favorite rhythm game, osu!mania. The layout of your beatmap consists of nn rows and 44 columns. Because notes at the bottom are closer, you will process the bottommost row first and the topmost row last. Each row will contain exactly one note, represented as a '#'.

For each note 1,2,…,n1,2,…,n, in the order of processing, output the column in which the note appears.

Input

The first line contains tt (1≤t≤1001≤t≤100) — the number of test cases.

For each test case, the first line contains nn (1≤n≤5001≤n≤500) — the number of rows of the beatmap.

The following nn lines contain 44 characters. The ii-th line represents the ii-th row of the beatmap from the top. It is guaranteed that the characters are either '.' or '#', and exactly one of the characters is '#'.

It is guaranteed that the sum of nn over all test cases does not exceed 500500.

Output

For each test case, output nn integers on a new line, the column that the ii-th note appears in for all ii from 11 to nn.

Example

Input

3

4

#...

.#..

..#.

...#

2

.#..

.#..

1

...#

Output

Copy

4 3 2 1 
2 2 
4 
t = int(input())  # 读取测试用例数
for _ in range(t):
    n = int(input())  # 读取每个测试用例中的行数
    rows = [input() for _ in range(n)]  # 读取每一行

    result = []
    for row in reversed(rows):  # 从最后一行开始处理
        for i in range(4):  # 每行有4列
            if row[i] == '#':  # 找到音符 '#'
                result.append(i + 1)  # 列从1开始计数,i是0索引
                break

    print(" ".join(map(str, result)))  # 输出结果

题目翻译

你正在玩你最喜欢的节奏游戏 osu!mania。节奏图的布局由 n 行和 4 列组成。由于最下面的音符更靠近屏幕,你将首先处理最下面的那一行,然后依次处理上面行的音符。每一行都会包含一个音符,音符用 # 表示。

对于每个音符,从第 1 行到第 n 行,按顺序输出每个音符所在的列。

输入

  • 第一行包含一个整数 t (1 ≤ t ≤ 100) — 测试用例的数量。
  • 对于每个测试用例:
    • 第一行包含一个整数 n (1 ≤ n ≤ 500) — 节奏图的行数。
    • 接下来的 n 行,每行包含 4 个字符,表示节奏图的每一行。每一行都保证只有一个字符为 #,其他字符为 .

保证所有测试用例中 n 的总和不超过 500。

输出

对于每个测试用例,输出 n 个整数,表示每一行的音符出现在第几列。列的编号从 1 到 4。

题解

  1. 题目分析:

    • 每个测试用例给定一个节奏图,由 n 行和 4 列组成。每一行只有一个 #,其余是 .
    • 我们需要从下到上处理每一行,找出 # 出现在哪一列,并输出对应的列号。
  2. 解题步骤:

    • 对于每个测试用例,读取输入的节奏图。
    • 从最底行(也就是最后输入的行)开始,找到 # 所在的列,列号是从 1 开始数的。
    • 将找到的列号按顺序输出。
  3. 具体实现:

    • 首先读取输入的测试用例数 t
    • 对每个测试用例,读取 n 行的节奏图。
    • 对于每一行,从后向前找出 # 所在的列,然后按顺序输出。
  4. 时间复杂度:

    • 每个测试用例需要处理 n 行,每行的长度为 4。遍历每个字符的时间复杂度为 O(n)。总的复杂度约为 O(t * n)。

       

      处理过程:

    • 第一个测试用例:
      • 行从底部到顶部依次为 ...#, ..#., .#.., #...,对应的列号为 4, 3, 2, 1。
    • 第二个测试用例:
      • 行从底部到顶部依次为 .#.., .#..,对应的列号为 2, 2。
    • 第三个测试用例:
      • 行只有一行 ...#,对应的列号为 4。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ws_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值