Submission #512582

#TimeUsernameProblemLanguageResultExecution timeMemory
512582sidonTeams (CEOI11_tea)C++17
0 / 100
386 ms38620 KiB
#include <bits/stdc++.h> using namespace std; const int Z = 1e6+1, oo = 2e9; int N, A[Z], S[Z]; array<int, 3> F[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++) { array<int, 3> best = {-oo}; for(int j = i - A[S[i]] + 1; j >= 1; j -= j&-j) best = max(best, F[j]); ++best[0]; swap(best[1], best[2]); best[1] = i; for(int j = i + 1; j <= N+1; j += j&-j) F[j] = max(F[j], best); } vector<vector<int>> res = {{}}; int curr = F[N+1][2]; for(int i = N + 1; --i; ) { if(curr == i) { res.push_back({}); curr = F[i+1][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...