# Simplified Reversi SOLUTION AtCoder Beginner Contest 179

Page Contents

## Simplified Reversi SOLUTION

Problem Statement
There is a framework with N columns and N segments of squares. Let ( I , j
)
be the square at the
I
– th column from the top and the
j
– th segment from the left.
Every one of the focal
(
N
2
)
×
(
N
2
)
squares in the lattice has a dark stone on it. Each of the
2
N
1
squares on the base side and the correct side has a white stone on it.
Q
inquiries are given. We request that you cycle them all together. There are two sorts of inquiries. Their information arrangement and portrayal are as per the following:
1 x: Place a white stone on
(
1
,
x
)
. From that point onward, for each dark stone between
(
1
,
x
)
also, the principal white stone you hit in the event that you go down from
(
1
,
x
)
, supplant it with a white stone.
2 x: Place a white stone on
(
x
,
1
)
. From that point forward, for each dark stone between
(
x
,
1
)
furthermore, the primary white stone you hit in the event that you go directly from
(
x
,
1
)
, supplant it with a white stone.
The number of dark stones are there on the framework subsequent to handling all
Q
questions?
Limitations
3
N
2
×
10
5
0
Q
min
(
2
N
4
,
2
×
10
5
)
2
x
N
1
Questions are pairwise unmistakable.
Info
Info is given from Standard Input in the accompanying configuration:
N
Q
Q
u
e
r
y
1
Q
u
e
r
y
Q
Yield
Print the number of dark stones there are on the network in the wake of preparing all
Q
inquiries.
Test Input 1
Duplicate
5
1 3
2 3
1 4
2
1 2
Test Output 1
Duplicate
1
After each inquiry, the network changes in the accompanying way:
Figure
Test Input 2
Duplicate
200000 0
Test Output 2
Duplicate
39999200004
Test Input 3
Duplicate
176527 15
1 81279
2 22308
2 133061
1 80744
2 44603
1 170938
2 139754
2 15220
1 172794
1 159290
2 156968
1 56426
2 77429
1 97459
2 71282
Test Output 3
Duplicate
31159505795