#include <stdio.h>

int main() {
    //n 배열 크기, m 반복횟수
    int n,m,ball[101];
    int s,e,tmp;
    scanf("%d %d",&n,&m);
    for (int i=1;i<=n;i++) {
        ball[i]=i;
    }
    for (int i=0; i<m; i++) {
        scanf("%d %d",&s,&e);
        for (int j=s; j<=(s+e)/2; j++) {
            tmp=ball[j];
            ball[j]=ball[e-j+s];
            ball[e-j+s]=tmp;     
        }
    }
    for(int i=1; i<=n; i++){
        printf("%d ",ball[i]);
    }

    return 0;
}




Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: