Advertisement
GerONSo

F всесиб

Dec 29th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. /*
  2. ┓┏┓┏┓┃
  3. ┛┗┛┗┛┃
  4. ┓┏┓┏┓┃
  5. ┛┗┛┗┛┃
  6. ┓┏┓┏┓┃\○/
  7. ┛┗┛┗┛┃ / /
  8. ┓┏┓┏┓┃ノ
  9. ┛┗┛┗┛┃
  10. ┓┏┓┏┓┃
  11. ┛┗┛┗┛┃
  12. ┓┏┓┏┓┃
  13. ┛┗┛┗┛┃
  14. ┓┏┓┏┓┃
  15. ┛┗┛┗┛┃
  16. ┓┏┓┏┓┃┓
  17. ┛┗┛┗┛┃┃
  18. MIPTCLASSICMIPTCLASSICMIPTCLASSICMIPTCLASSICMIPTCLASSICMIPTCLASSIC
  19. */
  20.  
  21. // #define pragma
  22.  
  23. #ifdef pragma
  24. #pragma GCC optimize("Ofast")
  25. #pragma GCC optimize("no-stack-protector")
  26. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  27. #pragma GCC optimize("unroll-loops")
  28. #pragma GCC diagnostic ignored "-Wunused-result"
  29. #endif // pragma
  30.  
  31. #include<bits/stdc++.h>
  32. #include <ext/pb_ds/assoc_container.hpp>
  33. #include <ext/pb_ds/tree_policy.hpp>
  34.  
  35. #define ll long long
  36. #define all(x) begin(x), end(x)
  37. #define pb push_back
  38. #define x first
  39. #define y second
  40. #define int long long
  41. #define zero(two) memset(two, 0, sizeof(two))
  42.  
  43. using namespace std;
  44. using namespace __gnu_pbds;
  45.  
  46.  
  47. typedef vector<int> vi;
  48. typedef vector<bool> vb;
  49. typedef pair<int, int> pii;
  50. typedef long double ld;
  51. typedef vector<vi> matrix;
  52. template<typename T>
  53. using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  54.  
  55. const ld PI = atan2(0, -1);
  56.  
  57. void seriy() {
  58. ios::sync_with_stdio(0);
  59. cin.tie(0);
  60. cout.tie(0);
  61. cout << fixed << setprecision(10);
  62. #if _offline
  63. freopen("input", "r", stdin);
  64. freopen("output", "w", stdout);
  65. #endif
  66. }
  67.  
  68. const int INF = 1e9 + 7;
  69. const int MAXN = 101;
  70.  
  71. vector<vi> t(MAXN);
  72.  
  73. void update(int v, int tl, int tr, int ver, int pos, int val) {
  74. if(tl > pos || tr < pos) {
  75. return;
  76. }
  77. if(tl == tr) {
  78. t[ver][v] = val;
  79. return;
  80. }
  81. int tm = (tl + tr) >> 1;
  82. update(v * 2 + 1, tl, tm, ver, pos, val);
  83. update(v * 2 + 2, tm + 1, tr, ver, pos, val);
  84. t[ver][v] = min(t[ver][v * 2 + 1], t[ver][v * 2 + 2]);
  85. }
  86.  
  87. int get(int v, int tl, int tr, int ver, int l, int r) {
  88. if(tl > r || tr < l) {
  89. return INF;
  90. }
  91. if(tl >= l && tr <= r) {
  92. return t[ver][v];
  93. }
  94. int tm = (tl + tr) >> 1;
  95. int left = get(v * 2 + 1, tl, tm, ver, l, r);
  96. int right = get(v * 2 + 2, tm + 1, tr, ver, l, r);
  97. return min(left, right);
  98. }
  99.  
  100. signed main() {
  101. seriy();
  102. int a, b, c;
  103. cin >> a >> b >> c;
  104. if(a > 40 || b > 40 || c > 40) {
  105. assert(0);
  106. }
  107. bool m[a][b][c];
  108. int d[b][c];
  109. for(int j = 0; j < b; j++) {
  110. for(int k = 0; k < c; k++) {
  111. d[j][k] = -1;
  112. }
  113. }
  114. for(int i = 0; i < a; i++) {
  115. for(int j = 0; j < b; j++) {
  116. for(int k = 0; k < c; k++) {
  117. char ch;
  118. cin >> ch;
  119. m[i][j][k] = (ch == '1');
  120. }
  121. }
  122. }
  123. int ans = 0;
  124. for(int i = 0; i < a; i++) {
  125. for(int j = 0; j < b; j++) {
  126. if(i == 0) {
  127. t[j].resize(4 * MAXN);
  128. }
  129. else {
  130. t[j].assign(4 * MAXN, 0);
  131. }
  132. for(int k = 0; k < c; k++) {
  133. if(m[i][j][k]) {
  134. d[j][k] = i;
  135. }
  136. update(0, 0, MAXN - 1, j, k, i - d[j][k]);
  137. }
  138. }
  139. for(int j = 0; j < b; j++) {
  140. for(int k = j; k < b; k++) {
  141. vi tmp(c);
  142. for(int h = 0; h < c; h++) {
  143. tmp[h] = get(0, 0, MAXN - 1, h, j, k);
  144. }
  145.  
  146. }
  147. }
  148. }
  149. cout << ans;
  150. return 0;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement