diff --git a/problem/P3391/P3391.cpp b/problem/P3391/P3391.cpp new file mode 100644 index 00000000..71009813 --- /dev/null +++ b/problem/P3391/P3391.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +int main() { + vector a; + int n, m, l, r; + scanf("%d%d", &n, &m); + for (int i = 0; i <= n; i++) { + a.push_back(i); + } + for (int i = 0; i < m; i++) { + scanf("%d%d", &l, &r); + reverse(a.begin() + l, a.begin() + r + 1); + } + for (int i = 1; i < a.size(); i++) { + printf("%d ", a[i]); + } + printf("\n"); + return 0; +}