AT_ndpc2026_h.Coin

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given an N×NN \times N grid. Let (i,j)(i,j) denote the cell in the ii-th row from the top and the jj-th column from the left.

The state of each cell is described by NN strings S1,S2,…,SNS_1, S_2, \dots, S_N, each of length NN.
If the jj-th character of SiS_i is @, then cell (i,j)(i,j) contains one coin. If it is ., then the cell is empty.

You start at cell (1,1)(1,1). It is guaranteed that (1,1)(1,1) is empty.

You may perform the following action any number of times (including zero):

  • Let your current position be (i,j)(i,j). Move to either the right cell (i,j+1)(i,j+1) or the down cell (i+1,j)(i+1,j). You cannot move outside the grid. If the destination cell contains a coin, you must pick it up.

For each x=0,1,…,2N−2x = 0, 1, \dots, 2N-2, solve the following:

  • After performing some actions (possibly zero), you reach a cell (i,j)(i,j) while having exactly xx coins. How many possible cells (i,j)(i,j) are there?

给你一个 N×NN \times N 的网格。用 (i,j)(i,j) 表示从上往下数第 ii 行、从左往右数第 jj 列的格子。

每个格子的状态由 NN 个长度均为 NN 的字符串 S1,S2,…,SNS_1, S_2, \dots, S_N 描述:
若 SiS_i 的第 jj 个字符为 @,则格子 (i,j)(i,j) 中有一枚硬币;若为 .,则该格子为空。

你起始于格子 (1,1)(1,1),题目保证 (1,1)(1,1) 为空。

你可以执行以下操作任意多次(包括零次):

  • 设你当前位于格子 (i,j)(i,j),可移动至右侧格子 (i,j+1)(i,j+1) 或下方格子 (i+1,j)(i+1,j)。你不能移出网格边界。若目标格子中含有一枚硬币,则你必须拾取它。

对每个 x=0,1,…,2N−2x = 0, 1, \dots, 2N-2,求解以下问题:

  • 在执行若干次(可能为零次)操作后,你抵达某个格子 (i,j)(i,j),且此时恰好持有 xx 枚硬币。满足该条件的格子 (i,j)(i,j) 共有多少个?

输入格式

The input is given from standard input in the following format:

NN
S1S_1
S2S_2
⋮\vdots
SNS_N

输入从标准输入中按以下格式给出:

NN
S1S_1
S2S_2
⋮\vdots
SNS_N

输出格式

Print 2N−12N-1 lines. On the ii-th line, output the answer for x=i−1x = i-1.

输出 2N−12N-1 行。在第 ii 行中,输出 x=i−1x = i-1 时的答案。

输入输出样例

  • 输入#1

    3
    .@@
    ..@
    @..

    输出#1

    5
    6
    3
    2
    0
  • 输入#2

    7
    ...@@@.
    ..@@@@@
    @...@..
    ..@..@.
    .....@@
    .@@@@@@
    @@.@.@.

    输出#2

    15
    29
    28
    23
    19
    13
    6
    5
    3
    0
    0
    0
    0

说明/提示

Partial Score

This problem has partial scoring.

  • If you solve the dataset with N≤1500N \leq 1500, you will get 22 points.

Sample 1 Explanation:
For example, when x=0x=0, the possible cells (i,j)(i,j) are (1,1),(2,1),(2,2),(3,2),(3,3)(1,1), (2,1), (2,2), (3,2), (3,3), so there are 55 such cells.

Constraints

  • 2≤N≤40002 \leq N \leq 4000
  • S1,S2,…,SNS_1, S_2, \dots, S_N are strings of length NN consisting of @ and .
  • The first character of S1S_1 is .
  • NN is an integer

部分得分

本题采用部分得分制。

  • 若你解决了满足 N≤1500N \leq 1500 的数据集,则可获得 22 分。

样例 1 解释:
例如,当 x=0x=0 时,满足条件的格子 (i,j)(i,j) 有 (1,1),(2,1),(2,2),(3,2),(3,3)(1,1), (2,1), (2,2), (3,2), (3,3),共 55 个。

约束条件

  • 2≤N≤40002 \leq N \leq 4000
  • S1,S2,…,SNS_1, S_2, \dots, S_N 是由字符 @ 和 . 组成的长度为 NN 的字符串;
  • S1S_1 的第一个字符为 .;
  • NN 是一个整数。

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

首页