#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int s[N];
int cnt[N];
/*主要思路是什么呢?我们想到对一个后缀全部加上一个数来说的话是影响这个后缀的单调性的,这也就意味着我们的后缀加上某个数与
后缀无关,而仅仅与加上后缀的第一个数,和这个数的前一个数有关,我们只需要判断这两个数的大小关系即可,那么,如何让这个数保证大呢?
很简单直接让后一个数加上那一个数本身,就一定大了。*/
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
s[i] = a[i] - a[i - 1];
cnt[i] = 0;
}
for (int i = 1; i <= n; i++) {
if (s[i] > 0)
continue;
cnt[a[i - 1]] = i;
}
for (int i = 1; i <= n; i++) {
if (!cnt[i])
cnt[i] = 1;
}
for (int i = 1; i <= n; i++) {
printf("%d ", cnt[i]);
}
printf("\n");
}
return 0;
}
codeforces day 5 Permutation Operations
最新推荐文章于 2024-05-20 15:29:54 发布