题解:AT_abc392_f [ABC392F] Insert
FrozenRose · · 题解
看了一圈题解区的大佬们的代码也太长了,发一篇自己的。
STL: rope
众所周知,rope 是一个类似平衡树的东西,支持很多操作。
介绍其中的
a.insert(pos,x) 在
又已知 rope 可以使用 for(auto i:a)进行遍历。
所以本题就直接最朴素地做,大概 16 行,目前见到过的最短的 F:
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
rope<int>tr;
int main()
{
int n;cin>>n;
for(int i=1;i<=n;i++)
{
int x;cin>>x;x--;
tr.insert(x,i);
}
for(auto i:tr)cout<<i<<' ';
return 0;
}