This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int a[3][n];
int pos[3][n];
vector <int> cnt(3, 0);
for(int i = 0; i < 3; i++)
{
for(int j = 0;j < n; j++)
{
cin >> a[i][j];
a[i][j]--;
pos[i][a[i][j]] = j;
}
}
vector <int> cnt1(n, 0);
for(int i = 0; i < n; i++)
{
for(int j = i + 1; j < n; j++)
{
vector <pair <pair <int, int>, int> > mass;
for(int t = 0; t < 3; t++)
{
int f1 = min(pos[t][i], pos[t][j]);
int f2 = max(pos[t][i], pos[t][j]);
mass.push_back({{f1, f2}, t});
}
sort(mass.begin(), mass.end());
int ind = mass[0].second;
if(pos[ind][i] < pos[ind][j])
{
cnt1[i]++;
}
else
{
cnt1[j]++;
}
cnt[ind]++;
}
}
for(int i = 0; i < 3; i++)
{
cout << cnt[i] << " ";
}
cout << "\n";
for(int i = 0; i < n; i++)
{
cout << cnt1[i] << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |