#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, s, t;
cin >> n >> s >> t;
vector<vector<int>> a(n, vector<int>(s));
for (int i = 0; i < n; i++) {
for (int j = 0; j < s; j++) {
cin >> a[i][j];
--a[i][j];
}
}
function<void(int, int)> Solve = [&](int l, int r) {
if (l == r) {
return;
}
int mid = (l + r) >> 1;
Solve(l, mid);
Solve(mid + 1, r);
vector<vector<int>> cnt(t, vector<int>(2));
for (int i = 0; i < n; i++) {
if (cnt[a[i][0]][0] != cnt[a[i][0]][1]) {
if (cnt[a[i][0]][0] > cnt[a[i][0]][1]) {
swap(a[i][0], a[i][1]);
}
} else if (cnt[a[i][1]][0] != cnt[a[i][1]][1]) {
if (cnt[a[i][1]][0] < cnt[a[i][1]][1]) {
swap(a[i][0], a[i][1]);
}
}
cnt[a[i][0]][0] += 1;
cnt[a[i][1]][1] += 1;
}
};
Solve(0, s - 1);
for (int i = 0; i < n; i++) {
for (int j = 0; j < s; j++) {
cout << a[i][j] + 1 << " ";
}
cout << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Correct |
0 ms |
348 KB |
Correct |
4 |
Incorrect |
0 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
12464 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
12464 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Correct |
2 |
Correct |
0 ms |
348 KB |
Correct |
3 |
Correct |
0 ms |
348 KB |
Correct |
4 |
Incorrect |
0 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
12464 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
12464 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Correct |
2 |
Incorrect |
0 ms |
348 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
3 |
Halted |
0 ms |
0 KB |
- |