Codeforces Round #656 (Div. 3) B. Restore the Permutation by Merger (模拟)

-
题意:有两个完全相同的排列,将其中一个的元素按相对顺序插入另外一个排列中,给你操作完的排列,求原排列.
-
题解:感觉看看样例就能直接写了啊,直接遍历,用桶存数字个数,如果桶为空,直接输出即可.
-
代码:
int t; int n; vector<int> v; map<int,int> mp; int main() { ios::sync_with_stdio(false);cin.tie(0); cin>>t; while(t--){ cin>>n; mp.clear(); v.clear(); for(int i=1;i<=2*n;++i){ int x; cin>>x; if(!mp[x]){ v.pb(x); } mp[x]++; } for(auto w:v){ cout<<w<<" "; } cout<<endl; } return 0; }
𝓐𝓬𝓱𝓲𝓮𝓿𝓮𝓶𝓮𝓷𝓽 𝓹𝓻𝓸𝓿𝓲𝓭𝓮𝓼 𝓽𝓱𝓮 𝓸𝓷𝓵𝔂 𝓻𝓮𝓪𝓵
𝓹𝓵𝓮𝓪𝓼𝓾𝓻𝓮 𝓲𝓷 𝓵𝓲𝓯𝓮

浙公网安备 33010602011771号