Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #pragma optimize GCC("ofast")
  2. #include<bits/stdc++.h>
  3. #define ll long long
  4. #define pb push_back
  5. #define ld long double
  6. #define f first
  7. #define s second
  8. using namespace std;
  9. int main()
  10. {
  11. ios_base::sync_with_stdio(0);
  12. cin.tie(0);
  13. cout.tie(0);
  14. freopen("input.txt", "r", stdin);
  15. freopen("output.txt", "w", stdout);
  16. ll n, m[3];
  17. cin >> n >> m[0] >> m[1] >> m[2];
  18. unordered_map<ll, vector<ll>>mp;
  19. for(int i = 0; i < 3; i++)
  20. {
  21. for(int j = 0; j < m[i]; j++)
  22. {
  23. ll a;
  24. cin >> a;
  25. mp[a].pb(i);
  26. }
  27. }
  28. ll k1[3] = {0,0,0};
  29. for(int i = 1; i <= n; i++)
  30. {
  31. if(int(mp[i].size()) == 1)
  32. {
  33. k1[mp[i][0]]++;
  34. }
  35. }
  36.  
  37. for(int i = 1; i <= n; i++)
  38. {
  39. ll mi = 1e9, no = -1;
  40. if(int(mp[i].size()) != 1) {
  41.  
  42. for(auto to: mp[i] )
  43. {
  44. if(int(k1[to]) < mi) {mi = k1[to]; no = to; k1[to]++;}
  45. }
  46. }
  47. else no = mp[i][0];
  48. cout << no + 1 << ' ';
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement