tuki2501

bando.cpp

Nov 25th, 2021 (edited)
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define taskname "bando"
  5.  
  6. typedef long long ll;
  7.  
  8. void ioset() {
  9.   cin.tie(0)->sync_with_stdio(0);
  10.   if (fopen(taskname".inp", "r")) {
  11.     freopen(taskname".inp", "r", stdin);
  12.     // freopen(taskname".out", "w", stdout);
  13.   }
  14. }
  15.  
  16. const int N = 1005 * 2;
  17.  
  18. int n, m, a[N][N];
  19. int sx, sy, tx, ty;
  20.  
  21. void solve() {
  22.   cin >> n >> m >> sx >> sy >> tx >> ty;
  23.   sx *= 2; sy *= 2; tx *= 2; ty *= 2;
  24.  
  25.   for (int i = 1; i <= n * 2 + 1; i++) {
  26.     a[i][1] = a[i][m * 2 + 1] = 1;
  27.   }
  28.   for (int i = 1; i <= m * 2 + 1; i++) {
  29.     a[1][i] = a[n * 2 + 1][i] = 1;
  30.   }
  31.   for (int i = 1; i <= n * 2 + 1; i += 2)
  32.   for (int j = 1; j <= m * 2 + 1; j += 2) {
  33.     if (i % 2 || j % 2) a[i][j] = 1;
  34.   }
  35.  
  36.   for (int i = 2; i <= n * 2; i += 2)
  37.   for (int j = 2; j <= m * 2; j += 2) {
  38.     int x; cin >> x;
  39.     if (x == 1) {
  40.       a[i][j + 1] = 1;
  41.     }
  42.     else if (x == 2) {
  43.       a[i + 1][j] = 1;
  44.     }
  45.     else if (x == 3) {
  46.       a[i][j + 1] = 1;
  47.       a[i + 1][j] = 1;
  48.     }
  49.   }
  50.   for (int i = 1; i <= n * 2 + 1; i++)
  51.   for (int j = 1; j <= m * 2 + 1; j++) {
  52.     if (i % 2 == 0 && j % 2 == 0) {
  53.       cout << "  ";
  54.     }
  55.     else cout << a[i][j] << ' ';
  56.     if (j == m * 2 + 1) cout << '\n';
  57.   }
  58. }
  59.  
  60. int main() {
  61.   ioset();
  62.   solve();
  63. }
  64.  
Add Comment
Please, Sign In to add comment