Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/detail/standard_policies.hpp>
  3. #include <ext/pb_ds/assoc_container.hpp>
  4. #include <ext/pb_ds/tree_policy.hpp>
  5. #include <immintrin.h>
  6.  
  7. #define pb push_back
  8. #define F first
  9. #define S second
  10. #define ll long long
  11. #define ld long double
  12. #define pii pair <int, int>
  13. #define ull unsigned long long
  14. //#define int long long
  15.  
  16. //#pragma comment(linker, "/stack:200000000")
  17. //#pragma GCC optimize("Ofast")
  18. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  19. #pragma GCC optimize("unroll-loops")
  20. #pragma GCC optimize("-O3")
  21.  
  22. using namespace std;
  23. using namespace __gnu_pbds;
  24.  
  25. template <typename T>
  26. using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
  27.  
  28. mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
  29.  
  30. const int N = 2e3 + 1;
  31. const int M = 3e4 + 5;
  32. const ll mod = 1e9 + 81;
  33. const int rx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
  34. const int ry[8] = {0, 0, 1, -1, 1, -1, 1, -1};
  35. const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
  36. const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};
  37. const ld pi = acos(-1.0);
  38. const ld eps = 1e-9;
  39.  
  40. int a[N][N * 5];
  41.  
  42. #define kek __m128i
  43.  
  44. __attribute__((target("avx"))) void KEK(int *up, int *down, int len) {
  45. for (int i = len - len % 8; i < len; ++i) swap(up[i], down[i]);
  46. kek* l = (kek*)up;
  47. kek* r = (kek*)down;
  48. for (int i = 0; i < len / 8; ++i, l += 2, r += 2) {
  49. kek a = _mm_loadu_si128(l);
  50. kek b = _mm_loadu_si128(l + 1);
  51. kek c = _mm_loadu_si128(r);
  52. kek d = _mm_loadu_si128(r + 1);
  53. _mm_storeu_si128((kek*)l, c);
  54. _mm_storeu_si128((kek*)l + 1, d);
  55. _mm_storeu_si128((kek*)r, a);
  56. _mm_storeu_si128((kek*)r + 1, b);
  57. }
  58.  
  59. }
  60.  
  61. #define FILE "e"
  62. int main() {
  63. ios_base::sync_with_stdio(0);
  64. cin.tie(0);
  65. cout.tie(0);
  66. #ifdef LOCAL
  67. freopen("input.txt", "r", stdin);
  68. freopen("output.txt", "w", stdout);
  69. #else
  70. // freopen(FILE".in", "r", stdin);
  71. //freopen(FILE".out", "w", stdout);
  72. #endif // LOCAL
  73. int n, m;
  74. cin >> n >> m;
  75. for (int i = 0; i < n; i++) {
  76. for (int j = 0; j < m; j++) {
  77. a[i][j] = i * m + j;
  78. }
  79. }
  80. int q;
  81. cin >> q;
  82. if (1ll * n * m * q < 1e8) {
  83. while (q--) {
  84. char t;
  85. int x1, y1, x2, y2;
  86. cin >> t >> x1 >> y1 >> x2 >> y2;
  87. x1--, y1--, x2--, y2--;
  88. if (t == 'V') {
  89. for (int j = y1; j <= y2; ++j) {
  90. for (int i = 0; i < (x2 - x1 + 1) >> 1; ++i) {
  91. swap(a[x1 + i][j], a[x2 - i][j]);
  92. }
  93. }
  94.  
  95. } else {
  96. for (int i = x1; i <= x2; ++i) {
  97. for (int j = 0; j < (y2 - y1 + 1) >> 1; ++j) {
  98. swap(a[i][y1 + j], a[i][y2 - j]);
  99. }
  100. }
  101. }
  102. }
  103. } else {
  104. while (q--) {
  105. char t;
  106. int x1, y1, x2, y2;
  107. cin >> t >> x1 >> y1 >> x2 >> y2;
  108. x1--, y1--, x2--, y2--;
  109. if (t == 'V') {
  110. for (int i = 0; i < (x2 - x1 + 1) >> 1; ++i) {
  111. KEK(a[x1 + i] + y1, a[x2 - i] + y1, y2 - y1 + 1);
  112. }
  113. } else {
  114. for (int i = x1; i <= x2; ++i) {
  115. for (int j = 0; j < (y2 - y1 + 1) >> 1; ++j) {
  116. swap(a[i][y1 + j], a[i][y2 - j]);
  117. }
  118. }
  119. }
  120. }
  121. }
  122. for (int i = 0; i < n; i++) {
  123. ll x = 0;
  124. for (int j = 0; j < m; j++) {
  125. x += a[i][j];
  126. }
  127. cout << x << " ";
  128. }
  129. cout << "\n";
  130. for (int j = 0; j < m; j++) {
  131. ll x = 0;
  132. for (int i = 0; i < n; i++) {
  133. x += a[i][j];
  134. }
  135. cout << x << " ";
  136. }
  137. cout << "\n";
  138. cerr << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
  139. return 0;
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement