#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 100 * 1000 + 10, INF = 1e9;
int n, done;
int p[3][nax];
int inv[nax][3];
int ind[3];
bool visited[nax];
int ans[nax];
int res[3];
void match(int a, int b) {
if(a == b) return;
pi best = {INF, INF};
for(int i = 0; i < 3; ++i) {
best = min(best, {min(inv[a][i], inv[b][i]), max(inv[a][i], inv[b][i])});
}
for(int i = 0; i < 3; ++i) {
if(make_pair(min(inv[a][i], inv[b][i]), max(inv[a][i], inv[b][i])) == best) {
if(inv[a][i] < inv[b][i]) ans[a]++;
else ans[b]++;
res[i]++;
return;
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int j = 0; j < 3; ++j) {
for(int i = 1; i <= n; ++i) {
cin >> p[j][i];
inv[p[j][i]][j] = i;
}
ind[j] = 1;
}
for(int i = 1; i <= n; ++i) {
for(int j = i + 1; j <= n; ++j) {
match(i, j);
}
}
for(int i = 0; i < 3; ++i) cout << res[i] << " ";
cout << "\n";
for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
//while(done < n) {
//for(int i = 0; i < 3; ++i) {
//while(visited[p[i][ind[i]]]) ind[i]++;
//}
//}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
118 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
118 ms |
460 KB |
Output is correct |
5 |
Execution timed out |
1089 ms |
2000 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |