Code: Select all

```
3 2 4
1 1
-1 -1
1 1
```

Code: Select all

```
0 0
-1 -1
0 0
0 0
-1 -1
1 1
0 0
-1 -1
2 2
1 1
-1 -1
0 0
2 2
-1 -1
0 0
1 1
-1 -1
1 1
```

**Moderator:** Board moderators

This last sample case outputs 4:
Which 2 of these are not a solution and why?

Code: Select all

```
3 2 4
1 1
-1 -1
1 1
```

Code: Select all

```
0 0
-1 -1
0 0
0 0
-1 -1
1 1
0 0
-1 -1
2 2
1 1
-1 -1
0 0
2 2
-1 -1
0 0
1 1
-1 -1
1 1
```

I got the same question and sent a clarification request, which is not answered yet.

Anyway I solved it now. It's about the interpretation of

It means that in the end no cell may contain more marbles than it had initially. Hence, solutionsFor the same reason, they do not want the final arrangement to have more stones than the initial grid configuration does.

Code: Select all

```
2 2
-1 -1
0 0
0 0
-1 -1
2 2
```

I got Accepted this way.

Cu, Erik

So L is the maximum total number of stones allowed in an arrangement, and each cell can't have more stones than what it has in the initial configuration.

I'll have to rewrite much of my program to fix this.

Each cell is either odd or even. A cell (i,j) is odd(even) iff (i+j)%2 is odd(even).

A bigger hint:

Think about connected components.

There exists a sequence of moves to move any stone on odd(even) cell to any other odd(even) cell in the same component, leaving the number of stones on all other cells unchanged.

Another hint:

If we remove any stones from an odd(even) cell, we must remove an equal number of stones from an adjacent even(odd) cell.

My hints are enough to solve this problem.

Code: Select all

```
5
1 2 0
-1 1
3 2 4
1 1
-1 1
1 0
4 4 20
8 9 0 -1
-1 2 1 9
9 2 3 6
5 -1 -1 -1
4 4 10
3 9 0 -1
-1 -1 -1 9
0 2 3 6
5 -1 2 -1
4 4 14
9 9 0 -1
-1 -1 -1 9
7 2 -1 6
5 -1 2 -1
```

Code: Select all

```
0
4
2784
18
65
```