logo AlgoBeat OnlineJudge
登录 注册

#214155. [SDCPC 2019] BaoBao Loves Reading

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

BaoBao is a good student who loves reading, but compared with his huge bookshelf containing lots and lots of books, his reading desk, which can only hold at most books, is surprisingly small.

Today BaoBao decides to read some books for minutes by the desk. According to his reading plan, during the -th minute, he is scheduled to read book . The reading desk is initially empty and all the books are initially on the shelf. If the book BaoBao decides to read is not on the desk, BaoBao will have to fetch it from the shelf. Also, if the desk is full and BaoBao has to fetch another book from the shelf, he will have to put one book back from the desk to the shelf before fetching the new book.

Tired of deciding which book to put back, BaoBao searches the Internet and discovers an algorithm called the (LRU) algorithm. According to the algorithm, when BaoBao has to put a book back from the desk to the shelf, he should put back the least recently read book.

For example, let's consider the reading plan and assume that the capacity of the desk is 3. The following table explains what BaoBao should do according to the LRU algorithm. Note that in the following table, we use a pair of integer to represent a book, where is the index of the book, and is the last time when this book is read.

Given the reading plan, what's the number of times BaoBao fetches a book from the shelf if the value of (the capacity of the desk) ranges from 1 to (both inclusive)?

输入格式

There are multiple test cases. The first line of the input contains an integer , indicating the number of test cases. For each test case:

The first line contains an integer (), indicating the length of the reading plan.

The second line contains integers (), indicating the indices of the books to read.

It's guaranteed that the sum of of all test cases will not exceed .

输出格式

For each test case output one line containing integers separated by a space, where indicates the number of times BaoBao fetches a book from the shelf when the capacity of the desk is .

Please, DO NOT output extra spaces at the end of each line, or your solution may be considered incorrect!

样例

样例输入 1

1
7
4 3 4 2 3 1 4

样例输出 1

7 6 5 4 4 4 4