Open Rohyoohyun opened 2 months ago
#include <stdio.h> int main(){ int n, m; scanf("%d %d", &n, &m); int arr[n]; for (int i=0; i<n; i++) arr[i] = i+1; for (int i=0; i<m; i++){ int temp, a, b; scanf("%d %d", &a, &b); for (int j=0; j< (b-a)/2+1; j++){ temp = arr[a+j-1]; arr[a+j-1] = arr[b-1-j]; arr[b-j-1] = temp; } } for (int i=0; i<n; i++) printf("%d ", arr[i]); return 0; }