#P6579. [Ynoi2019] Happy Sugar Life
[Ynoi2019] Happy Sugar Life
Background
I never understood—
What does “warmth” feel like?
What is “gentleness”?
What is “cherishing”?

More importantly…
I cannot understand what “love” is.
But now, I understand—
I finally understand the true meaning of love.

—This shining feeling is probably love.
I swear—
Whether in sickness or in health,
Whether in happiness or in sorrow,
Whether rich or poor,
Until death,
I will regard Satou as my dearest, never parting until death.

I had never loved anyone before.
Being confessed to by someone whispering in my ear—
That has happened many times.
But, whether it was sweet talk,
Or whatever they did,
I could not feel anything.

Satou-chan, does it hurt?
—I’m fine, but… I can’t go to a new castle anymore.
—I’m sorry.
It’s fine.
After all, I am happiest when I’m with Satou-chan.
—Shio…

Hey, Satou-chan, I’ve thought about it—
Back then, when I was abandoned by mom,
I was probably already like I was dead.
Sad and painful,
Feeling like nothing mattered, the world was completely blank—
But then Satou-chan appeared.
Meeting Satou, living together, being very happy.
—Me too, Shio.

So, I want to be with Satou-chan.
I want to be happy with Satou until the end.
So, let’s die together, Satou!
—Shio…

I originally didn’t know
What warmth feels like,
What gentleness is,
Or what kindness is.
Most importantly,
I could not understand what “love” was.
This is all thanks to Shio.
Because at that time Shio held my hand,
Because Shio showed me the way,
I came to understand the meaning of happiness that I had never felt in my life.
I always didn’t realize
That the one who taught me what love is
Was also Shio.
Shio, after you are reincarnated, confess to me again.
Sorry.
Thank you.

This is my
Problem Description
Satou and Shio give you a 2D plane. For two points on the plane, we say they form a dominance pair (denoted as ) if and only if .
Initially, there are distinct points on the plane.
You need to answer queries. Each query gives two points and asks how many ordered pairs satisfy and .
Input Format
The first line contains two integers .
The second line contains integers. The -th integer indicates that the -th initially given point on the plane is . It is guaranteed that is a permutation of to .
Then there are lines. Each line contains four integers separated by spaces, , representing one query. It is guaranteed that .
Output Format
Output lines. The -th line contains one integer, the answer to the -th query.
9 9
9 8 7 6 2 4 5 3 1
4 9 3 6
2 9 1 8
3 8 2 4
3 9 2 7
2 8 1 6
1 9 1 9
1 3 5 7
2 3 3 3
6 6 6 6
1
4
2
4
4
4
0
0
0
Hint
Idea: ccz181078 & nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: nzhtl1477 & ccz181078.
For of the data, , .
Sample Explanation
For the first query, the points that satisfy are . The dominance pair is , and the corresponding ordered pair is .
For the second query, the points that satisfy are . The dominance pairs are , , , and , and the corresponding ordered pairs are .
For the third query, the points that satisfy are . The dominance pairs are and , and the corresponding ordered pairs are .
For the fourth query, the points that satisfy are . The dominance pairs are , , , and , and the corresponding ordered pairs are .
For the fifth query, the points that satisfy are . The dominance pairs are , , , and , and the corresponding ordered pairs are .
For the sixth query, the points that satisfy are $(1,9),(2,8),(3,7),(4,6),(5,2),(6,4),(7,5),(8,3),(9,1)$. The dominance pairs are , , , and , and the corresponding ordered pairs are .
For the seventh query, the points that satisfy are , and there are no dominance pairs.
For the eighth query, there are no points satisfying , and there are no dominance pairs.
For the ninth query, there are no points satisfying , and there are no dominance pairs.
Input Format
Output Format
Hint
Translated by ChatGPT 5