| Baozii Cup 3 |
|---|
| Finished |
You are given an array $$$a$$$ of length $$$n$$$. Find the longest even-length palindromic subsequence of $$$a$$$.
The first line of each test contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the length of $$$a$$$.
The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le 10^5$$$) — the elements of $$$a$$$.
It is guaranteed that, except for the sample test, the elements of $$$a$$$ are generated uniformly at random in the range $$$[1,10^5]$$$, and each element occurs at least twice in $$$a$$$. Specifically, $$$a$$$ is generated by the following C++ code:
Firstly, output an even integer $$$m$$$ ($$$2 \le m \le n$$$) on a single line, representing the length of the longest even-length palindromic subsequence of $$$a$$$.
Then, output $$$m$$$ integers $$$b_1,b_2,\ldots,b_m$$$ ($$$1 \le b_i \le 10^5$$$) on a single line, representing the subsequence you found. If there are multiple longest even-length palindromic subsequences, you may output any of them.
71 1 4 5 1 4 5
2 5 5
92 10 2 10 1 9 2 1 9
4 2 10 10 2
| Name |
|---|


