Submission #512600

#TimeUsernameProblemLanguageResultExecution timeMemory
512600sidonTeams (CEOI11_tea)C++17
0 / 100
360 ms51264 KiB
#include <bits/stdc++.h> using namespace std; const int Z = 1e6+2, oo = 2e9; int N, A[Z], S[Z]; array<int, 3> F[Z], DP[Z]; int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> N; for(int i = 1; i <= N; i++) { cin >> A[i]; S[i] = i; F[i + 1] = {-oo}; } sort(S, S + N + 1, [&](int i, int j) { return A[i] < A[j]; }); for(int i = 1; i <= N; i++) { DP[i] = {-oo}; for(int j = i - A[S[i]] + 1; j >= 1; j -= j&-j) DP[i] = max(DP[i], F[j]); ++DP[i][0]; swap(DP[i][1], DP[i][2]); DP[i][1] = i; for(int j = i + 1; j <= N+1; j += j&-j) F[j] = max(F[j], DP[i]); } vector<vector<int>> res = {{}}; int curr = DP[N][2]; for(int i = N + 1; --i; ) { if(curr == i) { res.push_back({}); curr = DP[i][2]; } res.back().push_back(S[i]); } cout << size(res) << '\n'; for(auto &V : res) { cout << size(V); for(auto &i : V) cout << ' ' << i; cout << '\n'; } }
#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...