배열을 뒤집는 문제
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> v;
for (int i = 0; i < N; i++)
v.push_back(i + 1);
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
for (int j = 0; j < (b - a) / 2 +1; j++) {
int tmp = v[a + j - 1];
v[a + j - 1] = v[b - j - 1];
v[b - j - 1] = tmp;
}
}
for (int i = 0; i < N; i++)
cout << v[i] << " ";
return 0;
}