# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
862266 | 2023-10-17T21:40:32 Z | AbdelmagedNour | Volontiranje (COCI21_volontiranje) | C++17 | 0 ms | 344 KB |
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; int a[n],lis[n]={}; for(int i=0;i<n;i++)cin>>a[i]; vector<int>dp; for(int i=0;i<n;i++){ auto it=upper_bound(dp.begin(),dp.end(),a[i]); if(it==dp.end())dp.push_back(a[i]),lis[i]=dp.size(); else *it=a[i],lis[i]=it-dp.begin(); } int mx=dp.size(); vector<vector<int>>lvl(mx+1); for(int i=0;i<n;i++)lvl[lis[i]].push_back(i); for(int i=1;i<=mx;i++)reverse(lvl[i].begin(),lvl[i].end()); vector<vector<int>>ans; vector<int>cur; while(!lvl[1].empty()||!cur.empty()){ if(cur.empty())cur.push_back(lvl[1].back()),lvl[1].pop_back(); else if(cur.size()==mx)ans.push_back(cur),cur.clear(); else{ int nxt=cur.size()+1; while(!lvl[nxt].empty()&&lvl[nxt].back()<cur.back())lvl[nxt].pop_back(); if(!lvl[nxt].empty()&&a[lvl[nxt].back()]>a[cur.back()])cur.push_back(lvl[nxt].back()),lvl[nxt].pop_back(); else cur.pop_back(); } } cout<<ans.size()<<" "<<mx<<"\n"; for(auto v:ans){ for(auto x:v)cout<<x+1<<" "; cout<<"\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Integer parameter [name=number of subsequences] equals to 0, violates the range [1, 7] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Integer parameter [name=number of subsequences] equals to 0, violates the range [1, 7] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Integer parameter [name=number of subsequences] equals to 0, violates the range [1, 7] |
2 | Halted | 0 ms | 0 KB | - |