| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 474675 | Mr_OK_Man | Knjige (COCI20_knjige) | C++17 | 45 ms | 2680 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()
{
    long long n,q=0;
    cin>>n;
     stack<long long>l,d;
    vector<string >ans1,ans2,ans3;
    long long p[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
        b[i]=p[i];
    }
    for(int i=n-1;i>=0;i--)
    {
        l.push(p[i]);
    }
    sort(b,b+n);
    for(int i=0;i<n;i++)
    {
        if(b[i]==p[i])q++;
    }
    if(q==n)
    {cout<<0<<endl;
    return 0;
    }
    long long h=n-1,c=0;
    long long m=0,k=0;
     long long r=1;
    while(h>=0)
    {
        while(l.empty()==0)
        {
              c++;
            if(l.top()==b[h]&&h==n-1)
            {
                ans1.push_back("UZMI");
                ans2.push_back("L");
                ans3.push_back("L");
        /*    cout<<"UZMI"<<" ";
            cout<<"L"<<" "<<"L";*/
            l.pop();
            r=0;
                continue;
            }
           // cout<<l.top()<<endl;
          ans1.push_back("UZMI");
          ans2.push_back("D");
          ans3.push_back("L");
           /* cout<<"UZMI"<<" ";
            cout<<"D"<<" "<<"L";*/
            c++;
            ans1.push_back("STAVI");
          ans2.push_back("D");
          ans3.push_back("D");
          /*
            cout<<"STAVI"<<" ";
            cout<<"D"<<" "<<"D";*/
            d.push(l.top());
            l.pop();
        }
       c++;
        ans1.push_back("STAVI");
        ans2.push_back("L");
        ans3.push_back("L");
         h--;
           /* cout<<"STAVI"<<" ";
            cout<<"L"<<" "<<"L";*/
    if(h==-1)
    {
        break;
    }
     long long g=1;
        while(d.empty()==0)
        {
              c++;
            if(d.top()==b[h]&&g==1)
            {
                ans1.push_back("UZMI");
                ans2.push_back("L");
                ans3.push_back("D");
           /* cout<<"UZMI"<<" ";
            cout<<"L"<<" "<<"D";*/
            d.pop();
            g=0;
            continue;
            }
            /*cout<<h<<endl;
            cout<<d.top()<<endl;*/
           ans1.push_back("UZMI");
            ans2.push_back("D");
            ans3.push_back("D");
        /*    cout<<"UZMI"<<" ";
            cout<<"D"<<" "<<"D";*/
            c++;
        ans1.push_back("STAVI");
          ans2.push_back("D");
          ans3.push_back("L");
          /*
            cout<<"STAVI"<<" ";
            cout<<"D"<<" "<<"L";*/
            l.push(d.top());
            d.pop();
        }
    }/*
while(d.empty()==0)
        {
              c++;
                ans1.push_back("UZMI");
                ans2.push_back("D");
                ans3.push_back("D");
            cout<<"UZMI"<<" ";
            cout<<"D"<<" "<<"D";
                  ans1.push_back("STAVI");
          ans2.push_back("D");
          ans3.push_back("L");
            /*cout<<"STAVI"<<" ";
            cout<<"D"<<" "<<"L";
            d.pop();
        }*/
        cout<<c<<endl;
        for(int i=0;i<c;i++)
        {
            cout<<ans1[i]<<" "<<ans2[i]<<" "<<ans3[i]<<endl;
        }
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
