askarulytarlan

D regional

Dec 7th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n, a[1500];
  6. pair <int, int> b[1500];
  7.  
  8. int main(){
  9. //freopen("D.in", "r", stdin);
  10. //freopen("D.out", "w", stdout);
  11. cin >> n;
  12. for(int i = 1; i <= n; i++){
  13. cin >> a[i];
  14. }
  15. for(int i = 1; i <= n; i++){
  16. cin >> b[i].first;
  17. b[i].second = i;
  18. }
  19. for(int i = 1; i <= n; i++){
  20. cout << b[a[i]].second<< " " << i << endl;
  21. if(b[a[i]].first != i){
  22. cout << "NO";
  23. return 0;
  24. }
  25. }
  26. cout << "YES" << endl;
  27. return 0;
  28. }
Add Comment
Please, Sign In to add comment