Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <string>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- using unt = unsigned int;
- void cv(vector <unt> v){
- for (auto x: v) cout<<x<<' ';
- cout<<'\n';
- }
- int mx_lvl;
- vector <int> level(11);
- vector <vector < vector <int> > > wrk(10, vector <vector <int> > (1000, vector <int > (1000)));
- int n,L;
- void make(){
- for (int lvl=1;lvl<=mx_lvl;++lvl){
- int till = n - level[lvl];
- for (int i = 0;i<=till;++i){
- for (int j=0;j<=till;++j){
- int a,b,c,d;
- a = wrk[lvl-1][i][j];
- b = wrk[lvl-1][i][j+level[lvl-1]];
- c = wrk[lvl-1][i+level[lvl-1]][j];
- d = wrk[lvl-1][i+level[lvl-1]][j+level[lvl-1]];
- wrk[lvl][i][j] = min(min(a,b), min(c,d));
- }
- }
- }
- }
- void slv(){
- int till = n - L;
- for (int i =0;i<=till;++i){
- for (int j = 0;j<=till;++j){
- int a,b,c,d;
- a = wrk[mx_lvl][i][j];
- b = wrk[mx_lvl][i][j+L-level[mx_lvl]];
- c = wrk[mx_lvl][i+L-level[mx_lvl]][j];
- d = wrk[mx_lvl][i+L-level[mx_lvl]][j+L-level[mx_lvl]];
- cout<<min(min(a,b), min(c,d))<<" ";
- }cout<<"\n";
- }
- }
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- for (int i=0;i<=10;++i){
- level[i] = pow(2, i);
- }
- cin>>n>>L;
- mx_lvl = log2(L);
- for (int i = 0;i < n;++i){
- for (int j=0;j<n;++j){
- cin>>wrk[0][i][j];
- }
- }
- make();
- slv();
- }
- /*
- 25000 20000000 1000000000 1000000000
- 0 0 0 0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement