# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745248 | Ahmed57 | Volontiranje (COCI21_volontiranje) | C++17 | 1 ms | 212 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;
int main(){
int n;
cin>>n;
vector<pair<int,int>> v;
for(int i = 0;i<n;i++){
int x;cin>>x;
v.push_back({x,i});
}
int be = 0, cnt = 0;
vector<vector<int>> ans;
bool ch[n] = {0};
while(1){
int dp[v.size()] = {0};
int pr[v.size()] = {0};
int all= -1 ,index = 0;
for(int i=0 ;i<v.size();i++){
if(ch[i])continue;
int ma = 0, ind =i;
for(int j = i-1;j>=0;j--){
if(ch[j])continue;
if(v[i].first>v[j].first){
if(ma<dp[j]){
ma=dp[j];
ind = j;
}
}
}
dp[i] = ma+1;
pr[i] = ind;
if(all<dp[i]){
all= dp[i];
index = i;
}
}
if(all<be){
break;
}
cnt++;
be = all;
ans.push_back({});
while(pr[index]!=index){
ch[index]=1;
ans.back().push_back(index);
index= pr[index];
}ans.back().push_back(index);
ch[index] = 1;
}
cout<<cnt<<" "<<be<<endl;
for(auto i:ans){
reverse(i.begin(),i.end());
for(auto j:i){
cout<<j+1<<" ";
}
cout<<endl;
}
return 0;
}
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... |