Advertisement
Saleh127

CF 1435B

Oct 25th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. ll n,m;
  14. cin>>n>>m;
  15. ll a[n*m+5],c[n*m+5],d,e,f,i,j,k,l;
  16.  
  17. for(i=0; i<n; i++)
  18. {
  19. for(j=0; j<m; j++)
  20. {
  21. cin>>d;
  22. a[d]=j;
  23. }
  24. }
  25.  
  26. for(i=0; i<m; i++)
  27. {
  28. for(j=0; j<n; j++)
  29. {
  30. cin>>d;
  31. c[d]=j;
  32. }
  33. }
  34. int ans[n+5][m+5];
  35. for(i=1;i<=n*m;i++)
  36. {
  37. ans[c[i]][a[i]]=i;
  38. }
  39. for(i=0; i<n; i++)
  40. {
  41. for(j=0; j<m; j++)
  42. {
  43. cout<<ans[i][j]<<" ";
  44. }
  45. cout<<endl;
  46. }
  47. }
  48.  
  49.  
  50. return 0;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement