Advertisement
zhukov000

Untitled

Jan 10th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #define loop(i,from,to) for (int i = from; i < to; ++i)
  2. #include <bits/stdc++.h>
  3.  
  4. using std::cin;
  5. using std::cout;
  6. using std::endl;
  7. using std::vector;
  8. using std::string;
  9. using std::pair;
  10. using std::set;
  11.  
  12. const int INF = 1e9+7;
  13. const double eps = 1e-6;
  14.  
  15.  
  16. signed main() {
  17.   freopen("input.txt", "r", stdin);
  18.   std::ios::sync_with_stdio(false);
  19.   cin.tie(0);
  20.   int a, b, k, x, y, t; cin >> a >> b >> k;
  21.   vector< vector<int> > map(a);
  22.   for (int i = 0; i < a; ++i)
  23.     map[i].resize(b, 0);
  24.   /*
  25.   1. *#   2. #*
  26.      ##      ##
  27.  
  28.   3. ##   4. ##
  29.      *#      #*
  30.   */
  31.   long long answ = 0;
  32.   for (int i = 0; i < k; ++i) {
  33.     cin >> t >> y >> x;
  34.     x--;
  35.     y--;
  36.     if ( y > a - 2 || x > b - 2 ) continue;
  37.     // cout << y << " " << x << " " << answ << endl;
  38.     switch (t) {
  39.       case 1:
  40.         if (!map[y + 1][x] && !map[y + 1][x + 1] && !map[y][x + 1]) {
  41.           map[y + 1][x]++;
  42.           map[y + 1][x + 1]++;
  43.           map[y][x + 1]++;
  44.           answ += 3;
  45.         }
  46.         break;
  47.       case 2:
  48.         if (!map[y][x] && !map[y + 1][x + 1] && !map[y + 1][x]) {
  49.           map[y][x]++;
  50.           map[y + 1][x + 1]++;
  51.           map[y + 1][x]++;
  52.           answ += 3;
  53.         }
  54.         break;
  55.       case 3:
  56.         if (!map[y][x] && !map[y][x + 1] && !map[y + 1][x + 1]) {
  57.           map[y][x]++;
  58.           map[y][x + 1]++;
  59.           map[y + 1][x + 1]++;
  60.           answ += 3;
  61.         }
  62.         break;
  63.       case 4:
  64.         if (!map[y + 1][x] && !map[y][x] && !map[y][x + 1]) {
  65.           map[y + 1][x]++;
  66.           map[y][x]++;
  67.           map[y][x + 1]++;
  68.           answ += 3;
  69.         }
  70.     }
  71.   }
  72.   cout << answ;
  73.   //std::cout << "Hello World!\n";
  74.   return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement