Reordering the Cows

Problem Info

Reordering the Cows

My Work

#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;
}

Add explanation of code here

What I have Tried

I used an unordered map to keep track of every cow and then simple brut force to find its ordering position by running a loop.

Question

Why I can’t able to submit?or How to submit file in useco?
Thanks for the help.
[/quote]

You did submit properly. You code is just incorrect.