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 sort(vector<int> inds, vector<vector<pair<int, int>>> &ans) {
if (inds.size() == 1) {
return 0;
}
vector<int> inds1, inds2;
for (int i = 0; i < (int)inds.size(); ++i) {
if (i % 2 == 0) {
inds1.push_back(inds[i]);
} else {
inds2.push_back(inds[i]);
}
}
int pos = max(sort(inds1, ans), sort(inds2, ans));
for (int i = 0; i < ((int)inds.size() + 1) / 2; ++i) {
if ((int)ans.size() <= pos) {
ans.push_back({});
}
for (int j = i; j + 1 < (int)inds.size(); j += 2) {
ans[pos].emplace_back(inds[j], inds[j + 1]);
}
pos++;
}
return pos;
}
void solve() {
int n;
cin >> n;
vector<int> a(n);
iota(a.begin(), a.end(), 1);
vector<vector<pair<int, int>>> ans;
sort(a, ans);
cout << ans.size() << '\n';
// for (auto v : ans) {
// for (auto p : v) {
// cout << "CMPSWP R" << p.first << " R" << p.second;
// if (p != v.back()) {
// cout << ' ';
// }
// }
// cout << '\n';
// }
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
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... |