CF209B.Pixels
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels of colors x and y (x ≠ y) meet in a violent fight, then the pixel that survives the fight immediately changes its color to z (z ≠ x; z ≠ y). Pixels of the same color are friends, so they don't fight.
The King of Flatland knows that his land will be peaceful and prosperous when the pixels are of the same color. For each of the three colors you know the number of pixels of this color that inhabit Flatland. Help the king and determine whether fights can bring peace and prosperity to the country and if it is possible, find the minimum number of fights needed to make the land peaceful and prosperous.
Flatland 由三种颜色的像素组成:红色、绿色和蓝色。已知:若两个不同颜色的像素发生激烈战斗,则仅有一个像素能幸存(即像素总数减少一个)。此外,若颜色为 x 和 y 的像素(x=y)发生激烈战斗,则幸存的像素会立即变为第三种颜色 z(其中 z=x 且 z=y)。同色像素是朋友,因此不会相互战斗。
Flatland 的国王知道:当所有像素均为同一种颜色时,他的国土将实现和平与繁荣。对于三种颜色,你已知每种颜色的像素数量。请帮助国王判断:通过战斗是否可能实现和平与繁荣?若可能,请找出使国土达成和平与繁荣所需的最少战斗次数。
输入格式
The first line contains three space-separated integers a, b and c (0 ≤ a, b, c ≤ 231; a + b + c > 0) — the number of red, green and blue pixels, correspondingly.
第一行包含三个以空格分隔的整数 a、b 和 c(0 ≤ a, b, c ≤ 231;a + b + c > 0),分别表示红色、绿色和蓝色像素的数量。
输出格式
Print a single number — the minimum number of pixel fights before the country becomes peaceful and prosperous. If making the country peaceful and prosperous is impossible, print -1.
输出一个整数——使该国变得和平与繁荣所需的最少像素战斗次数。如果无法使该国变得和平与繁荣,则输出 −1。
输入输出样例
输入#1
1 1 1
输出#1
1
输入#2
3 1 0
输出#2
3
说明/提示
In the first test sample the country needs only one fight to achieve peace and prosperity. Besides, it can be any fight whatsoever. For example, let's assume that the green and the blue pixels fight, then the surviving pixel will be red. As a result, after the fight there are two red pixels. There won't be other pixels.
In the second sample the following sequence of fights is possible: red and blue, green and red, red and blue. As a result, after all fights there is one green pixel left.
在第一个测试样例中,该国家仅需进行一次战斗即可实现和平与繁荣。此外,这次战斗可以是任意两种颜色像素之间的战斗。例如,假设绿色像素与蓝色像素战斗,则幸存的像素为红色。结果是,战斗后剩下两个红色像素,不再有其他像素。
在第二个样例中,以下战斗序列是可行的:红色与蓝色、绿色与红色、红色与蓝色。最终,经过所有战斗后,仅剩一个绿色像素。
输入解题思路,AI测评打分。不知道怎么写?