Submission #1038488

#TimeUsernameProblemLanguageResultExecution timeMemory
1038488MilosMilutinovicBrought Down the Grading Server? (CEOI23_balance)C++14
0 / 100
30 ms11356 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...