#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> mn(n, n - 1);
vector<vector<int>> a(3, vector<int> (n));
vector<vector<int>> id(3, vector<int> (n));
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < n; ++j) {
cin >> a[i][j];
--a[i][j];
id[i][a[i][j]] = j;
mn[a[i][j]] = min(mn[a[i][j]], j);
}
}
vector<int> suf(n);
for (int i = 0; i < n; ++i) {
suf[mn[i]]++;
}
for (int i = n - 2; i >= 0; --i) {
suf[i] += suf[i + 1];
}
vector<bool> vis(n);
vector<long long> c(3), p(n);
for (int j = 0; j < n - 1; ++j) {
for (int i = 0; i < 3; ++i) {
if (vis[a[i][j]]) {
continue;
}
vis[a[i][j]] = true;
c[i] += suf[j + 1];
p[a[i][j]] += suf[j + 1];
for (int k = i + 1; k < 3; ++k) {
if (vis[a[k][j]]) {
continue;
}
if (id[k][a[i][j]] < id[i][a[k][j]]) {
c[k]++;
p[a[k][j]]++;
} else {
c[i]++;
p[a[i][j]]++;
}
}
}
}
for (int i = 0; i < 3; ++i) {
cout << c[i] << " \n"[i == 2];
}
for (int i = 0; i < n; ++i) {
cout << p[i] << " \n"[i == n - 1];
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Partially correct |
0 ms |
348 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Partially correct |
0 ms |
348 KB |
Partially correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Partially correct |
0 ms |
348 KB |
Partially correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Partially correct |
13 ms |
2240 KB |
Partially correct |
6 |
Correct |
17 ms |
3180 KB |
Output is correct |
7 |
Incorrect |
22 ms |
3872 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |