Advertisement
Rofyda_Elghadban1

Untitled

Sep 19th, 2023
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1.  #include <bits/stdc++.h>
  2.  #define ll long long
  3.  #define ull unsigned long long
  4.  #define pi 3.141592654
  5.  #define NUM 1e18
  6.  #define Mod  1'000'000'007
  7.  #define fixed(n) fixed<<setprecision(n)
  8.  #define cin(v) for(auto &i:v) cin >> i ;
  9.  #define cout(v) for(auto &i:v) cout << i  <<" ";
  10.  #define vowel(x) (x=='e'||x=='a'||x=='i'||x=='o'||x=='u')
  11.  #define small(x) (x>=97&&x<=122)
  12.  #define capital(x) (x>=65&&x<=90)
  13.  #define Tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
  14.  #define Toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
  15.  #define all(v) ((v).begin()), ((v).end())
  16.  #define allr(v) ((v).rbegin()), ((v).rend())
  17.  #define updmax(a,b) a=max(a,b)
  18.  #define updmin(a,b) a=min(a,b)
  19.  #define ceil(a,b) ((a/b)+(a%b?1:0))
  20.  /* asc -> 1 2 3 ,des -> 3 2 1 */
  21.  /***********************************************************************************/
  22.  using namespace std;
  23.  void Rofyda_Elghadban(){
  24.   #ifndef ONLINE_JUDGE  
  25.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  26.    #endif
  27.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  28.  }
  29.  
  30.  void solve(){
  31.   int n;
  32.   cin>>n;
  33.   vector<int>v(n),v2;
  34.   cin(v);
  35.   for(int i=0;i<n;i++){
  36.     if(v[i]<v[i+1]){
  37.       v2.push_back(v[i]);
  38.       cout<<"\n";
  39.     }else{
  40.       cout<<v[i]<<" ";
  41.       if(v2.size()>0){
  42.         reverse(all(v2));
  43.         cout(v2);
  44.         cout<<"\n";
  45.         v2.clear();
  46.       }
  47.     }
  48.   }
  49.  }
  50.  
  51.  int main(){
  52.   Rofyda_Elghadban();
  53.   solve();
  54.  
  55.   return 0;
  56.  }
  57.  
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement