CF988C.Equal Sums

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given kk sequences of integers. The length of the ii-th sequence equals to nin_i.

You have to choose exactly two sequences ii and jj (i≠ji \ne j) such that you can remove exactly one element in each of them in such a way that the sum of the changed sequence ii (its length will be equal to ni−1n_i - 1) equals to the sum of the changed sequence jj (its length will be equal to nj−1n_j - 1).

Note that it's required to remove exactly one element in each of the two chosen sequences.

Assume that the sum of the empty (of the length equals 00) sequence is 00.

给你 kk 个整数序列。第 ii 个序列的长度为 nin_i。

你需要恰好选择两个不同的序列 ii 和 jj(即 i≠ji \ne j),使得你能在每个序列中恰好移除一个元素,从而使修改后的序列 ii(其长度变为 ni−1n_i - 1)的元素和等于修改后的序列 jj(其长度变为 nj−1n_j - 1)的元素和。

注意:必须在所选的两个序列中各自恰好移除一个元素。

规定:空序列(长度为 00 的序列)的元素和为 00。

输入格式

The first line contains an integer kk (2≤k≤2⋅1052 \le k \le 2 \cdot 10^5) — the number of sequences.

Then kk pairs of lines follow, each pair containing a sequence.

The first line in the ii-th pair contains one integer nin_i (1≤ni<2⋅1051 \le n_i \lt 2 \cdot 10^5) — the length of the ii-th sequence. The second line of the ii-th pair contains a sequence of nin_i integers ai,1,ai,2,…,ai,nia_{i, 1}, a_{i, 2}, \dots, a_{i, n_i}.

The elements of sequences are integer numbers from −104-10^4 to 10410^4.

The sum of lengths of all given sequences don't exceed 2⋅1052 \cdot 10^5, i.e. n1+n2+⋯+nk≤2⋅105n_1 + n_2 + \dots + n_k \le 2 \cdot 10^5.

第一行包含一个整数 kk(2≤k≤2⋅1052 \le k \le 2 \cdot 10^5)—— 序列的个数。

接下来是 kk 对行,每对行表示一个序列。

第 ii 对行中,第一行包含一个整数 nin_i(1≤ni<2⋅1051 \le n_i \lt 2 \cdot 10^5)—— 第 ii 个序列的长度;第二行包含 nin_i 个整数 ai,1,ai,2,…,ai,nia_{i, 1}, a_{i, 2}, \dots, a_{i, n_i},即该序列的元素。

序列中的元素均为介于 −104-10^4 到 10410^4 之间的整数。

所有给定序列的长度之和不超过 2⋅1052 \cdot 10^5,即 n1+n2+⋯+nk≤2⋅105n_1 + n_2 + \dots + n_k \le 2 \cdot 10^5。

输出格式

If it is impossible to choose two sequences such that they satisfy given conditions, print "NO" (without quotes). Otherwise in the first line print "YES" (without quotes), in the second line — two integers ii, xx (1≤i≤k,1≤x≤ni1 \le i \le k, 1 \le x \le n_i), in the third line — two integers jj, yy (1≤j≤k,1≤y≤nj1 \le j \le k, 1 \le y \le n_j). It means that the sum of the elements of the ii-th sequence without the element with index xx equals to the sum of the elements of the jj-th sequence without the element with index yy.

Two chosen sequences must be distinct, i.e. i≠ji \ne j. You can print them in any order.

If there are multiple possible answers, print any of them.

如果无法选择两个满足给定条件的序列,则输出 "NO"(不带引号)。否则,第一行输出 "YES"(不带引号);第二行输出两个整数 ii、xx(1≤i≤k, 1≤x≤ni1 \le i \le k,\ 1 \le x \le n_i);第三行输出两个整数 jj、yy(1≤j≤k, 1≤y≤nj1 \le j \le k,\ 1 \le y \le n_j)。这表示:第 ii 个序列去掉下标为 xx 的元素后的元素之和,等于第 jj 个序列去掉下标为 yy 的元素后的元素之和。

所选的两个序列必须互不相同,即 i≠ji \ne j。你可以以任意顺序输出它们。

若存在多个可能的答案,输出任意一个即可。

输入输出样例

  • 输入#1

    2
    5
    2 3 1 3 2
    6
    1 1 2 2 2 1

    输出#1

    YES
    2 6
    1 2
  • 输入#2

    3
    1
    5
    5
    1 1 1 1 1
    2
    2 3

    输出#2

    NO
  • 输入#3

    4
    6
    2 2 2 2 2 2
    5
    2 2 2 2 2
    3
    2 2 2
    5
    2 2 2 2 2

    输出#3

    YES
    2 2
    4 1

说明/提示

In the first example there are two sequences [2,3,1,3,2][2, 3, 1, 3, 2] and [1,1,2,2,2,1][1, 1, 2, 2, 2, 1]. You can remove the second element from the first sequence to get [2,1,3,2][2, 1, 3, 2] and you can remove the sixth element from the second sequence to get [1,1,2,2,2][1, 1, 2, 2, 2]. The sums of the both resulting sequences equal to 88, i.e. the sums are equal.

在第一个例子中,有两个序列 [2,3,1,3,2][2, 3, 1, 3, 2] 和 [1,1,2,2,2,1][1, 1, 2, 2, 2, 1]。你可以从第一个序列中删除第二个元素,得到 [2,1,3,2][2, 1, 3, 2];也可以从第二个序列中删除第六个元素,得到 [1,1,2,2,2][1, 1, 2, 2, 2]。这两个新序列的和均为 88,即它们的和相等。

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

首页