given n points on a circle and all edges (C(2,n)) are drawn. Some of these edges are already colored in blue or red. You should find out how many ways are possible to color rested edges in order to have final picture with conditions below:
- all edges are colored.
- all triangles have 0 or 2 edges in red.
here are some examples:
example 1
input: n = 3 and 0 number of edges are already colored. output = 4 : because we can color all edges in blue or only one one of them in blue and rest of them in red.
example 2
input n = 4 and 4 number of edges are already colored
1 2 blue
2 3 blue
3 4 red
4 1 red
output = 1 : because the only way to color rested edges is like below:
1 3 blue
2 4 red
constraints:
- 3 <= n <= 100,000
- time limit : 1 second
- memory limit: 256 MB
actually I have no idea about ideal data structure for such question, and I need your help for some clues