[Solution] Points Codeforces Solution | Codeforces 2022
A triple of points , and on a coordinate line is called beautiful if and .
You are given a set of points on a coordinate line, initially empty. You have to process queries of three types:
- add a point;
- remove a point;
- calculate the number of beautiful triples consisting of points belonging to the set.
The first line contains two integers and () — the number of queries and the parameter for defining if a triple is beautiful, respectively.
Grass Field Codeforces Solution
Permutation Codeforces Solution
Schedule Management Codeforces Solution
Permutation Restoration Codeforces Solution
Text Editor Codeforces Solution
The second line contains integers () denoting the queries. The integer denotes the -th query in the following way:
- if the point belongs to the set, remove it; otherwise, add it;
- after adding or removing the point, print the number of beautiful triples.
For each query, print one integer — the number of beautiful triples after processing the respective query.
No comments:
Post a Comment