CF257B.Playing Cubes

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya and Vasya decided to play a little. They found n red cubes and m blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (overall the line will have n + m cubes). Petya moves first. Petya's task is to get as many pairs of neighbouring cubes of the same color as possible. Vasya's task is to get as many pairs of neighbouring cubes of different colors as possible.

The number of Petya's points in the game is the number of pairs of neighboring cubes of the same color in the line, the number of Vasya's points in the game is the number of neighbouring cubes of the different color in the line. Your task is to calculate the score at the end of the game (Petya's and Vasya's points, correspondingly), if both boys are playing optimally well. To "play optimally well" first of all means to maximize the number of one's points, and second — to minimize the number of the opponent's points.

佩佳和瓦夏决定玩一个小游戏。他们找到了 nn 个红色立方体和 mm 个蓝色立方体。游戏规则如下:双方轮流选择一个某种颜色(红色或蓝色)的立方体,并将其从左到右依次排成一行(最终该行将包含 n+mn + m 个立方体)。佩佳先手。佩佳的目标是使相邻且颜色相同的立方体对数尽可能多;瓦夏的目标是使相邻且颜色不同的立方体对数尽可能多。

游戏中佩佳的得分等于该行中相邻且颜色相同的立方体对的数量,瓦夏的得分等于该行中相邻且颜色不同的立方体对的数量。你的任务是:在双方均以最优策略进行游戏的前提下,计算游戏结束时的最终得分(即佩佳的得分和瓦夏的得分,按顺序给出)。所谓“以最优策略进行游戏”,首先意味着要最大化己方的得分,其次意味着在己方得分最大的前提下,尽可能最小化对方的得分。

输入格式

The only line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the number of red and blue cubes, correspondingly.

唯一一行包含两个以空格分隔的整数 nn 和 mm(1 ≤ n, m ≤ 1051 ≤ n, m ≤ 10^5),分别表示红色立方体和蓝色立方体的数量。

输出格式

On a single line print two space-separated integers — the number of Petya's and Vasya's points correspondingly provided that both players play optimally well.

在一行中输出两个用空格分隔的整数——分别为佩蒂亚和瓦夏的得分,前提是两名玩家均采取最优策略。

输入输出样例

  • 输入#1

    3 1

    输出#1

    2 1
  • 输入#2

    2 4

    输出#2

    3 2

说明/提示

In the first test sample the optimal strategy for Petya is to put the blue cube in the line. After that there will be only red cubes left, so by the end of the game the line of cubes from left to right will look as [blue, red, red, red]. So, Petya gets 2 points and Vasya gets 1 point.

If Petya would choose the red cube during his first move, then, provided that both boys play optimally well, Petya would get 1 point and Vasya would get 2 points.

在第一个测试样例中,Petya 的最优策略是将蓝色立方体放入序列中。此后,剩余的立方体均为红色,因此游戏结束时,从左到右的立方体序列将形如
[blue, red, red, red]。
于是,Petya 得 2 分,Vasya 得 1 分。

如果 Petya 在第一步选择红色立方体,则在双方均采取最优策略的前提下,Petya 将得 1 分,Vasya 将得 2 分。

输入解题思路,AI测评打分。不知道怎么写?

首页