Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define loop(i,from,to) for (int i = from; i < to; ++i)
- #include <bits/stdc++.h>
- using std::cin;
- using std::cout;
- using std::endl;
- using std::vector;
- using std::string;
- using std::pair;
- using std::set;
- const int INF = 1e9+7;
- const double eps = 1e-6;
- signed main() {
- freopen("input.txt", "r", stdin);
- std::ios::sync_with_stdio(false);
- cin.tie(0);
- int a, b, k, x, y, t; cin >> a >> b >> k;
- vector< vector<int> > map(a);
- for (int i = 0; i < a; ++i)
- map[i].resize(b, 0);
- /*
- 1. *# 2. #*
- ## ##
- 3. ## 4. ##
- *# #*
- */
- long long answ = 0;
- for (int i = 0; i < k; ++i) {
- cin >> t >> y >> x;
- x--;
- y--;
- if ( y > a - 2 || x > b - 2 ) continue;
- // cout << y << " " << x << " " << answ << endl;
- switch (t) {
- case 1:
- if (!map[y + 1][x] && !map[y + 1][x + 1] && !map[y][x + 1]) {
- map[y + 1][x]++;
- map[y + 1][x + 1]++;
- map[y][x + 1]++;
- answ += 3;
- }
- break;
- case 2:
- if (!map[y][x] && !map[y + 1][x + 1] && !map[y + 1][x]) {
- map[y][x]++;
- map[y + 1][x + 1]++;
- map[y + 1][x]++;
- answ += 3;
- }
- break;
- case 3:
- if (!map[y][x] && !map[y][x + 1] && !map[y + 1][x + 1]) {
- map[y][x]++;
- map[y][x + 1]++;
- map[y + 1][x + 1]++;
- answ += 3;
- }
- break;
- case 4:
- if (!map[y + 1][x] && !map[y][x] && !map[y][x + 1]) {
- map[y + 1][x]++;
- map[y][x]++;
- map[y][x + 1]++;
- answ += 3;
- }
- }
- }
- cout << answ;
- //std::cout << "Hello World!\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement