# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985677 | rembocoder | Volontiranje (COCI21_volontiranje) | C++17 | 1038 ms | 9564 KiB |
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;
#define int int64_t
// const int mod = 1e9 + 7;
const int inf = 2e18;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<bool> del(n, false);
int ans = -1;
vector<vector<int>> seqs;
while (true) {
vector<int> dp(n, -inf);
for (int i = n - 1; i >= 0; i--) {
if (del[i]) {
continue;
}
dp[i] = 1;
for (int j = i + 1; j < n; j++) {
if (!del[j] && a[j] > a[i]) {
dp[i] = max(dp[i], dp[j] + 1);
}
}
}
int cur = -inf;
for (int i = 0; i < n; i++) {
if (!del[i]) {
cur = max(cur, dp[i]);
}
}
if (ans == -1) {
ans = cur;
} else if (ans != cur) {
break;
}
seqs.push_back({});
int last = -1;
for (int i = 0; i < n; i++) {
if (del[i] || dp[i] != cur || (last != -1 && a[i] <= a[last])) {
continue;
}
last = i;
cur--;
seqs.back().push_back(i);
del[i] = true;
}
}
cout << seqs.size() << ' ' << ans << '\n';
for (int i = 0; i < seqs.size(); i++) {
for (int x: seqs[i]) {
cout << x + 1 << ' ';
}
cout << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |