fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. //
  4. const int maxn = 1e5;
  5. //
  6. int n, k, d, pos[maxn], nxt[maxn][31];
  7. //
  8. void process (void)
  9. {
  10. cin >> n >> k >> d;
  11. iota(pos, pos + n, 0);
  12. for (int l, r; k > 0; --k)
  13. {
  14. cin >> l >> r;
  15. --l, --r;
  16. while (l < r)
  17. swap(pos[l++], pos[r--]);
  18. }
  19.  
  20. for (int i = 0; i < n; ++i)
  21. nxt[i][0] = pos[i];
  22. for (int j = 1; j < 31; ++j)
  23. for (int i = 0; i < n; ++i)
  24. nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
  25. iota(pos, pos + n, 0);
  26. for (int j = 0; j < 31; ++j)
  27. if (d >> j & 1)
  28. for (int i = 0; i < n; ++i)
  29. pos[i] = nxt[pos[i]][j];
  30.  
  31. for (int i = 0; i < n; ++i)
  32. cout << pos[i] + 1 << ' ';
  33. }
  34. //
  35. signed main (void)
  36. {
  37. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  38. process();
  39. }
  40.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty