Advertisement
Korotkodul

2-D спарсы

Nov 30th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <set>
  5. #include <string>
  6. #include <algorithm>
  7. using namespace std;
  8. using ll = long long;
  9. using unt = unsigned int;
  10. void cv(vector <unt> v){
  11. for (auto x: v) cout<<x<<' ';
  12. cout<<'\n';
  13. }
  14. int mx_lvl;
  15. vector <int> level(11);
  16. vector <vector < vector <int> > > wrk(10, vector <vector <int> > (1000, vector <int > (1000)));
  17. int n,L;
  18. void make(){
  19. for (int lvl=1;lvl<=mx_lvl;++lvl){
  20. int till = n - level[lvl];
  21. for (int i = 0;i<=till;++i){
  22. for (int j=0;j<=till;++j){
  23. int a,b,c,d;
  24. a = wrk[lvl-1][i][j];
  25. b = wrk[lvl-1][i][j+level[lvl-1]];
  26. c = wrk[lvl-1][i+level[lvl-1]][j];
  27. d = wrk[lvl-1][i+level[lvl-1]][j+level[lvl-1]];
  28. wrk[lvl][i][j] = min(min(a,b), min(c,d));
  29. }
  30. }
  31. }
  32. }
  33.  
  34. void slv(){
  35. int till = n - L;
  36. for (int i =0;i<=till;++i){
  37. for (int j = 0;j<=till;++j){
  38. int a,b,c,d;
  39. a = wrk[mx_lvl][i][j];
  40. b = wrk[mx_lvl][i][j+L-level[mx_lvl]];
  41. c = wrk[mx_lvl][i+L-level[mx_lvl]][j];
  42. d = wrk[mx_lvl][i+L-level[mx_lvl]][j+L-level[mx_lvl]];
  43. cout<<min(min(a,b), min(c,d))<<" ";
  44. }cout<<"\n";
  45. }
  46. }
  47.  
  48. int main()
  49. {
  50. /*ios::sync_with_stdio(0);
  51. cin.tie(0);
  52. cout.tie(0);*/
  53. for (int i=0;i<=10;++i){
  54. level[i] = pow(2, i);
  55. }
  56. cin>>n>>L;
  57. mx_lvl = log2(L);
  58. for (int i = 0;i < n;++i){
  59. for (int j=0;j<n;++j){
  60. cin>>wrk[0][i][j];
  61. }
  62. }
  63. make();
  64. slv();
  65. }
  66. /*
  67. 25000 20000000 1000000000 1000000000
  68. 0 0 0 0
  69. */
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement