Files
hanyixuanten 2175f4f94c
Check cpp / md pair / Check md headers (push) Failing after 1s
new file: B3694.cpp
2026-10-23 10:56:41 +00:00

48 lines
998 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# B3694 【模板】数列离散化
## 题目描述
给定一个长度为 $n$ 的数列 $a$。定义 $\mathrm{rank}(i)$ 表示数列 $a$ 中比 $a_i$ 小的不同数字个数再加一。
对 $1 \leq i \leq n$,现在请你求出所有的 $\mathrm{rank}(i)$。
## 输入格式
**本题单测试点内有多组测试数据**。
输入的第一行是一个整数,表示数据组数 $T$。接下来依次给出每组数据的信息:
第一行是一个整数,表示数列长度 $n$。
第二行有 $n$ 个整数表示数列 $a$,第 $i$ 个整数表示 $a_i$。
## 输出格式
对每组数据,输出一行 $n$ 个整数,用空格隔开,依次表示 $\mathrm{rank}(1)$ 到 $\mathrm{rank}(n)$。
## 输入输出样例 #1
### 输入 #1
```
3
3
1 2 3
5
1 6 2 2 7
4
-1 -2 -3 -3
```
### 输出 #1
```
1 2 3
1 3 2 2 4
3 2 1 1
```
## 说明/提示
### 数据规模与约定
对全部的测试点,保证 $1 \leq T \leq 5$,$1 \leq n \leq 10^5$,$-10^9 \leq a_i \leq 10^9$。