http://www.usaco.org/index.php?page=viewproblem2&cpid=412
**I am trying to submit this code but facing file issue.It’s my first time submitting via file. Can anyone help me, what’s wrong?
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define q (float)clock()/CLOCKS_PER_SEC1000
int main()
{
freopen(“reorder.in”, “r”, stdin);
freopen(“reorder.out”, “w”, stdout);
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
unordered_map<int, int> mp;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
cin >> b[i];
if(a==b)cout<<"-1\n";
for (int i = 0; i < n; i++)
{
mp[b[i]] = i;
}
vector<int> p;
int cycle_count = 0, maxi;
for (int i = 0; i < n; i++)
{
int cycle_len = 1;
int initial = i;
int j = i, flag = 0;
while (mp[a[j]] != initial && count(p.begin(), p.end(), a[i]) == 0)
{
cycle_len++;
j = mp[a[j]];
p.push_back(a[j]);
if (flag == 0)
{
cycle_count++;
flag = 1;
}
}
maxi = max(maxi, cycle_len);
}
xx:
cout << cycle_count << " " << maxi << "\n";
return 0;
}