Advertisement
Korotkodul

CF

Jun 5th, 2023
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <cmath>
  11. #include <vector>
  12. #include <algorithm>
  13. using namespace std;
  14. #define pii pair <int,int>
  15.  
  16. void cv(vector <int> v) {
  17.     for (int i: v) {
  18.         cout << i << ' ';
  19.     } cout << "\n";
  20. }
  21.  
  22. bool cmp(pii a, pii b) {
  23.     return a.first < b.first;
  24. }
  25.  
  26. //https://codeforces.com/problemset/problem/1833/B
  27. void f() {
  28.     int n,k; cin >> n >> k;
  29.     vector <pii> a(n);
  30.     vector <int> b(n);
  31.     for (int i = 0; i < n; ++i) {
  32.         int x; cin >> x;
  33.         a[i].first = x;
  34.         a[i].second = i;
  35.     }
  36.     sort(a.begin(), a.end(), cmp);
  37.     for (int &i: b) cin >> i;
  38.     vector <int> ans;
  39.     for (int i = 0; i < n; ++i) {
  40.         ans[i] = b[i];
  41.     }
  42.     cv(ans);
  43. }
  44.  
  45. int main()
  46. {
  47.     int t; cin >> t;
  48.     for (int go = 0; go < t; ++go) {
  49.         f();
  50.     }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement