Advertisement
tuki2501

bitset

Jul 17th, 2020
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int n, m;
  5. bitset<30> X[30], Y[30];
  6.  
  7. bitset<30> get(bitset<30> a, int l, int r) {
  8.   bitset<30> b; b.set();
  9.   return (a >> l) & (b >> (30 - r + l - 1));
  10. }
  11.  
  12. int main() {
  13.   // freopen("in", "r", stdin);
  14.   cin >> n >> m;
  15.   for (int i = 1; i <= n; i++)
  16.   for (int j = 1; j <= m; j++) {
  17.     int t; cin >> t;
  18.     X[i][j] = t;
  19.     Y[j][i] = X[i][j];
  20.   }
  21.   int x0, y0, r;
  22.   cin >> x0 >> y0 >> r;
  23.   int x1 = x0 + r - 1;
  24.   int y1 = y0 + r - 1;
  25.   bitset<30> a = get(X[x0], y0, y1);
  26.   bitset<30> b = get(X[x1], y0, y1);
  27.   bitset<30> c = get(Y[y0], x0, x1);
  28.   bitset<30> d = get(Y[y1], x0, x1);
  29.   cout << a.to_string().substr(30 - r, r) << '\n';
  30.   cout << b.to_string().substr(30 - r, r) << '\n';
  31.   cout << c.to_string().substr(30 - r, r) << '\n';
  32.   cout << d.to_string().substr(30 - r, r) << '\n';
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement