Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n = 0, m = 0;
- scanf("%d%d", &n, &m);
- vector<vector<char>> tab(n, vector<char>(m, ' '));
- int x, y, guy = 1;
- int f = 0, s = 0;
- while (true)
- {
- cin >> x >> y;
- x--, y--;
- if (x < 0)
- break;
- auto place = [&tab, &x, &y, &m, &n] (char ne, char old, int& guy1, int& guy2)
- {
- int up = x - 1;
- for (; up >= 0; up--)
- if (tab[up][y] == ne)
- break;
- if (up != -1)
- {
- for (int i = x - 1; i > up; i--)
- {
- if (tab[i][y] == old)
- guy2--;
- tab[i][y] = ne;
- guy1++;
- }
- }
- int down = x + 1;
- for (; down < n; down++)
- if (tab[down][y] == ne)
- break;
- if (down != n)
- {
- for (int i = x + 1; i < down; i++)
- {
- if (tab[i][y] == old)
- guy2--;
- tab[i][y] = ne;
- guy1++;
- }
- }
- int right = y + 1;
- for (; right < m; right++)
- if (tab[x][right] == ne)
- break;
- if (right != m)
- {
- for (int i = y + 1; i < right; i++)
- {
- if (tab[x][i] == old)
- guy2--;
- tab[x][i] = ne;
- guy1++;
- }
- }
- int left = y - 1;
- for (; left >= 0; left--)
- if (tab[x][left] == ne)
- break;
- if (left != -1)
- {
- for (int i = y - 1; i > left; i--)
- {
- if (tab[x][i] == old)
- guy2--;
- tab[x][i] = ne;
- guy1++;
- }
- }
- };
- if (guy & 1)
- {
- if (tab[x][y] == 'B')
- s--;
- if (tab[x][y] != 'A')
- {
- tab[x][y] = 'A';
- f++;
- }
- place('A', 'B', f, s);
- }
- else
- {
- if (tab[x][y] == 'A')
- f--;
- if (tab[x][y] != 'B')
- {
- tab[x][y] = 'B';
- s++;
- }
- place('B', 'A', s, f);
- }
- cout << f - s << endl;
- guy++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement