답안 #395450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
395450 2021-04-28T11:15:45 Z MrRobot_28 Knjige (COCI20_knjige) C++17
50 / 50
3 ms 976 KB
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define sz(a) (int)a.size()
#define ll long long
#define ld long double

signed main()
{
    //ifstream cin("286.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <int> d(n);
    for(int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    vector <string> ans;
    vector <int> mass;
    for(int i = 0; i < n; i++)
    {
        ans.push_back("UZMI L L");
        int cnt = 0;
        vector <int> t;
        while(sz(mass) > 0 && mass.back() > d[i])
        {
            cnt++;
            ans.push_back("UZMI D D");
            t.push_back(mass.back());
            ans.push_back("STAVI D L");
            mass.pop_back();
        }
        ans.push_back("STAVI L D");
        mass.push_back(d[i]);
        while(cnt--)
        {
            mass.push_back(t.back());
            t.pop_back();
            ans.push_back("UZMI D L");
            ans.push_back("STAVI D D");
        }
    }
    while(n--)
    {
        ans.push_back("UZMI D D");
        ans.push_back("STAVI D L");
    }
    cout << sz(ans) << "\n";
    for(auto s : ans)
        cout << s << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 976 KB Output is correct
2 Correct 3 ms 976 KB Output is correct
3 Correct 2 ms 848 KB Output is correct
4 Correct 2 ms 848 KB Output is correct
5 Correct 2 ms 976 KB Output is correct
6 Correct 2 ms 976 KB Output is correct
7 Correct 2 ms 724 KB Output is correct
8 Correct 2 ms 976 KB Output is correct
9 Correct 3 ms 960 KB Output is correct
10 Correct 2 ms 976 KB Output is correct