알고리즘

[알고리즘] 백준 10812 - 바구니 순서 바꾸기

blueberrysoda 2024. 8. 22. 23:25
#include <iostream>
#include <vector>
using namespace std;

int N, M;
int Arr[101];
vector<int> V;

int main(){
    cin >> N >> M;

    for(int i=1; i<=N; i++){
        Arr[i] = i;
    }

    for(int i=0; i<M; i++){
        int A, B, C;
        cin >> A >> B >> C;

        int idx = 0; 
        V.clear();

        for(int j=C; j<=B; j++){
            V.push_back(Arr[j]);
        }
        for(int j=A; j<C; j++){
            V.push_back(Arr[j]);
        }
        for (int j=A; j<=B; j++){
            Arr[j] = V[idx];
            idx++;
        }
    }

    for (int i=1; i<=N; i++){
        cout << Arr[i] << " ";
    }
    cout << "\n";
    
    return 0;
}