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;
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(n, 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |