fork download
  1. // Problem: E. Hit and Blow
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. void solve()
  5. {
  6. int n;
  7. cin >> n;
  8. int a[1005], b[1005];
  9. for (int i = 0; i < n; i++)
  10. cin >> a[i];
  11. for (int i = 0; i < n; i++)
  12. cin >> b[i];
  13. int ans1 = 0;
  14. for (int i = 0; i < n; i++)
  15. {
  16. if (a[i] == b[i])
  17. ans1++;
  18. }
  19. int ans2 = 0;
  20. for (int i = 0; i < n; i++)
  21. {
  22. for (int j = 0; j < n; j++)
  23. {
  24. if (i == j)
  25. continue;
  26. if (a[i] == b[j])
  27. ans2++;
  28. }
  29. }
  30. cout << ans1 << "\n" << ans2;
  31. }
  32. int main()
  33. {
  34. int t = 1;
  35. // cin >> t;
  36. while (t--)
  37. {
  38. solve();
  39. }
  40. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
0
0