当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5353:Average

Special Judge 特殊评判
题目描述
There are $n$ soda sitting around a round table. soda are numbered from $1$ to $n$ and $i$-th soda is adjacent to $(i+1)$-th soda, $1$-st soda is adjacent to $n$-th soda.

Each soda has some candies in their hand. And they want to make the number of candies the same by doing some taking and giving operations. More specifically, every two adjacent soda $x$ and $y$ can do one of the following operations only once:
1. $x$-th soda gives $y$-th soda a candy if he has one;
2. $y$-th soda gives $x$-th soda a candy if he has one;
3. they just do nothing.

Now you are to determine whether it is possible and give a sequence of operations.
输入解释
There are multiple test cases. The first line of input contains an integer $T$, indicating the number of test cases. For each test case:

The first contains an integer $n$ $(1 \le n \le 10^5)$, the number of soda.
The next line contains $n$ integers $a_1, a_2, \dots, a_n$ $(0 \le a_i \le 10^9)$, where $a_i$ denotes the candy $i$-th soda has.
输出解释
For each test case, output "YES" (without the quotes) if possible, otherwise output "NO" (without the quotes) in the first line. If possible, then the output an integer $m$ $(0 \le m \le n)$ in the second line denoting the number of operations needed. Then each of the following $m$ lines contain two integers $x$ and $y$ $(1 \le x, y \le n)$, which means that $x$-th soda gives $y$-th soda a candy.
输入样例
3
6
1 0 1 0 0 0
5
1 1 1 1 1
3
1 2 3
输出样例
NO
YES
0
YES
2
2 1
3 2
来自杭电HDUOJ的附加信息
Author zimpha@zju
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5353

最后修改于 2020-10-25T23:21:57+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 131072/131072K(Java/Others)