Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace __gnu_pbds;
- using namespace std;
- using ui = unsigned int;
- using ll = long long;
- using ull = unsigned long long;
- using ld = long double;
- using pii = pair<int, int>;
- using pll = pair<ll, ll>;
- using vi = vector<int>;
- using vll = vector<ll>;
- using vvi = vector<vi>;
- using vpii = vector<pii>;
- template <typename key_type, typename value_type, typename comp = less<key_type>>
- using rbt_map = tree<key_type, value_type, comp, rb_tree_tag, tree_order_statistics_node_update>;
- template <typename key_type, typename comp = less<key_type>>
- using rbt_set = rbt_map<key_type, null_type, comp>;
- #define F(i, a, b) for(int i = (int)a; i <= (int)b; i++)
- #define f(i, a, b) for(int i = (int)a; i >= (int)b; i--)
- #define Fk(k, i, a, b) for(int i = (int)a; i <= (int)b; i += k)
- #define fk(k, i, a, b) for(int i = (int)a; i >= (int)b; i -= k)
- #define PB push_back
- #define MP make_pair
- #define MT make_tuple
- #define trans int tm = (tl + tr)>>1, l = v<<1, r = l|1
- template <typename value_type, typename relax_type = value_type, typename predictor = less<value_type>>
- void relax_pred(value_type& val, const relax_type& rel) { static predictor pred; if (pred(val, rel)) val = rel; }
- template <typename type>
- void relax_min(type& val, const type& rel) { relax_pred<type, type, greater<type>>(val, rel); }
- template <typename type>
- void relax_max(type& val, const type& rel) { relax_pred<type, type, less<type>>(val, rel); }
- ld const PI = acos(-1);
- ///#include "C:\programming\structures\IO_templates\int128_io.h"
- ///#include "C:\programming\structures\IO_templates\fast_io.h"
- ///#include "C:\programming\structures\big_integer.h"
- ///#include "C:\programming\structures\Math\Combinatorics.h"
- ///using namespace combinatorics;
- int const N = 5002;
- int mp[N][N];
- int cnt[2];
- pii mv[4] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
- void make_move(int pl, int x, int y) {
- if (mp[x][y] != 2)
- --cnt[mp[x][y]];
- mp[x][y] = pl;
- ++cnt[pl];
- for (auto [dx, dy] : mv) {
- int ex = -1, ey = -1;
- int cx = x + dx, cy = y + dy;
- for (; mp[cx][cy] != 3; cx += dx, cy += dy) {
- if (mp[cx][cy] == pl) {
- ex = cx, ey = cy;
- break;
- }
- }
- if (ex != -1) {
- cx = x + dx, cy = y + dy;
- for (; cx != ex || cy != ey; cx += dx, cy += dy) {
- if (mp[cx][cy] != 2)
- --cnt[mp[cx][cy]];
- mp[cx][cy] = pl;
- ++cnt[pl];
- }
- }
- }
- }
- //#define LOCAL
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- #ifdef LOCAL
- freopen("in", "r", stdin);
- freopen("out", "w", stdout);
- #endif
- int n, m;
- cin >> n >> m;
- F(i, 0, n + 1)
- F(j, 0, m + 1)
- mp[i][j] = (i == 0 || j == 0 || i == n + 1 || j == m + 1 ? 3 : 2);
- int x, y, turn = 0;
- cin >> x >> y;
- while (x != -1) {
- make_move(turn, x, y);
- cout << cnt[0] - cnt[1] << endl;
- cin >> x >> y;
- turn ^= 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement