/*
In the name of Allah
made by: Ahmed_Solyman
*/
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
cout<<(x?"YES":"NO")<<endl;
}
vector<int> LIS(vector<int>arr){
vector<int>v;
for(auto i:arr){
if(!v.size()){
v.push_back(i);
}
else{
if(v.back()<i){
v.push_back(i);
}
else{
v[(ub(all(v),i)-v.begin())]=i;
}
}
}
return v;
}
void run(){
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
#endif
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//run();
int n;cin>>n;
vector<int>arr(n);
map<int,int>mp;
int j=1;
for(auto &i:arr)cin>>i,mp[i]=j++;
int lis=LIS(arr).size();
int cnt=0;
vector<vector<int>>ans;
while(1){
vector<int>v=LIS(arr);
map<int,int>idx;
for(int i=0;i<arr.size();i++){
idx[arr[i]]=i;
}
if(v.size()==lis){
cnt++;
ans.push_back(v);
for(int i=lis-1;i>=0;i--){
arr.erase(arr.begin()+idx[v[i]]);
}
}
else{
break;
}
}
cout<<cnt<<" "<<lis<<endl;
for(auto i:ans){
for(auto j:i)cout<<mp[j]<<" ";
cout<<endl;
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:78:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(int i=0;i<arr.size();i++){
| ~^~~~~~~~~~~
Main.cpp:81:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
81 | if(v.size()==lis){
| ~~~~~~~~^~~~~
Main.cpp: In function 'void run()':
Main.cpp:57:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
57 | freopen("input.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:58:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
58 | freopen("output.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |