답안 #1006578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006578 2024-06-24T04:00:53 Z vjudge1 Knjige (COCI20_knjige) C++17
0 / 50
28 ms 1624 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;

    int a[n], d[n];
    for (int i = 0; i < n; i ++)
        cin >> d[i], a[i] = d[i];
    sort(a, a + n);

    int cur = n - 1;
    int done = 0;
    vector<pair<string, pair<char, char>>> vec;

    stack<int> left, right;
    for (int i = 0; i < n; i ++)
        left.push(d[i]);

    while (cur >= 0){
        int l = -1, r = -1;
        bool taken = 0;
        while (left.size() != done){
            int b = left.top();
            left.pop();

            if (b == a[cur] and !taken){
                taken = 1;
                l = b;
                vec.push_back({"UZMI", {'L', 'L'}});
            }
            else{
                r = b;
                vec.push_back({"UZMI", {'R', 'L'}});

                vec.push_back({"STAVI", {'R', 'R'}});
                right.push(r);
                r = -1;
            }
        }

        vec.push_back({"STAVI", {'L', 'L'}});
        left.push(l);
        l = -1;

        while (right.size()){
            int b = right.top();
            right.pop();

            r = b;
            vec.push_back({"UZMI", {'R', 'R'}});
            left.push(r);   
            r = -1;         
            vec.push_back({"STAVI", {'R', 'L'}});
        }

        cur--;
        done++;
    }

    // for (int i = 0; i < n; i ++)
    //     cout << d[i] << " ";
    // cout << endl;

    cout << vec.size() << endl;
    for (auto [s, P] : vec){
        auto [x, y] = P;
        cout << s << " " << x << " " << y << endl;
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:24:28: warning: comparison of integer expressions of different signedness: 'std::stack<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |         while (left.size() != done){
      |                ~~~~~~~~~~~~^~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 1620 KB Token "R" doesn't correspond to pattern "(L|D)"
2 Incorrect 26 ms 1620 KB Token "R" doesn't correspond to pattern "(L|D)"
3 Incorrect 22 ms 1620 KB Token "R" doesn't correspond to pattern "(L|D)"
4 Incorrect 22 ms 1620 KB Token "R" doesn't correspond to pattern "(L|D)"
5 Incorrect 22 ms 1624 KB Token "R" doesn't correspond to pattern "(L|D)"
6 Incorrect 27 ms 1624 KB Token "R" doesn't correspond to pattern "(L|D)"
7 Incorrect 22 ms 1624 KB Token "R" doesn't correspond to pattern "(L|D)"
8 Incorrect 28 ms 1620 KB Token "R" doesn't correspond to pattern "(L|D)"
9 Incorrect 22 ms 1624 KB Token "R" doesn't correspond to pattern "(L|D)"
10 Incorrect 23 ms 1624 KB Token "R" doesn't correspond to pattern "(L|D)"