#P7893. 『JROI-3』Reversi
『JROI-3』Reversi
Description
White is playing Reversi with a forest spirit race, but the rules of Reversi have been changed.
There are Reversi pieces. The -th piece is labeled . All pieces are initially black. During the game, only White operates. White wants to turn as many pieces as possible to white.
White requires that piece and piece cannot both be turned white at the same time.
White played games in total. In each game, White wants to know the maximum number of pieces that can be turned white. Each game is independent.
To avoid confusion, the bold White is a person’s name.
Input Format
The first line contains a positive integer , denoting the number of test cases.
The next lines each contain two integers , as described.
Output Format
Output lines. Each line contains one positive integer, denoting the maximum number of pieces that White can turn white.
1
3 2
2
1
100 5
84
Hint
Sample 1 Explanation
You can choose pieces to change color.
Constraints
This problem uses bundled tests.
- Subtask 1 (5 pts): , ;
- Subtask 2 (5 pts): , ;
- Subtask 3 (20 pts): , ;
- Subtask 4 (70 pts): no special constraints.
For of the testdata, , , .
// Fast input template
// During-contest reminder: fast input is not very necessary
inline long long read(){
long long s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
return s*w;
}
Translated by ChatGPT 5
京公网安备 11011102002149号