Advertisement
MinhNGUYEN2k4

Untitled

Sep 4th, 2021
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. //Nguyen Huu Hoang Minh
  2. #include <bits/stdc++.h>
  3. #define sz(x) int(x.size())
  4. #define all(x) x.begin(),x.end()
  5. #define reset(x) memset(x, 0,sizeof(x))
  6. #define pb push_back
  7. #define mp make_pair
  8. #define fi first
  9. #define se second
  10. #define N 300005
  11. #define remain(x) if (x > MOD) x -= MOD
  12. #define ii pair<int, int>
  13. #define iiii pair< ii , ii >
  14. #define viiii vector< iiii >
  15. #define vi vector<int>
  16. #define vii vector< ii >
  17. #define bit(x, i) (((x) >> (i)) & 1)
  18. #define Task "test"
  19. #define int long long
  20.  
  21. using namespace std;
  22.  
  23. typedef long double ld;
  24. const int inf = 1e10;
  25. const int minf = -1e10;
  26.  
  27. int n;
  28. int a[N], b[N], c[N];
  29. int pa[N], pb[N], pc[N];
  30.  
  31. void readfile()
  32. {
  33.     ios_base::sync_with_stdio(false);
  34.     cin.tie(0);cout.tie(0);
  35.     if (fopen(Task".inp","r"))
  36.     {
  37.         freopen(Task".inp","r",stdin);
  38.         //freopen(Task".out","w",stdout);
  39.     }
  40.     cin >> n;
  41.     for(int i=1; i<=n; i++){
  42.         cin >> a[i];
  43.         pa[a[i]] = i;
  44.     }
  45.     for(int i=1; i<=n; i++){
  46.         cin >> b[i];
  47.         pb[b[i]] = i;
  48.     }
  49.     for(int i=1; i<=n; i++){
  50.         cin >> c[i];
  51.         pc[c[i]] = i;
  52.     }
  53. }
  54.  
  55. map<ii,int> cnt;
  56.  
  57. void proc()
  58. {
  59.     int ans = 1;
  60.     for(int i=1; i<=n; i++){
  61.         int change1=0;
  62.         if (pb[i] > pa[i]){
  63.             change1 += n-pb[i]+pa[i];
  64.         }
  65.         else change1 += pa[i]-pb[i];
  66.         int change2 = 0;
  67.         if (pc[i] > pa[i]){
  68.             change2 += n-pc[i]+pa[i];
  69.         }
  70.         else change2 += pa[i]-pc[i];
  71.         cnt[ii(change1,change2)]++;
  72.         ans = max(ans,cnt[ii(change1,change2)]);
  73.     }
  74.     cout << ans;
  75. }
  76.  
  77. signed main()
  78. {
  79.     readfile();
  80.     proc();
  81.     return 0;
  82. }
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement