C. Equal Sums
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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

You have to choose exactly two sequences ii and jj (i≠ji≠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−1ni−1) equals to the sum of the changed sequence jj (its length will be equal to nj−1nj−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.

Input

The first line contains an integer kk (2≤k≤2⋅1052≤k≤2⋅105) — 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 nini (1≤ni<2⋅1051≤ni<2⋅105) — the length of the ii-th sequence. The second line of the ii-th pair contains a sequence of nini integers ai,1,ai,2,…,ai,niai,1,ai,2,…,ai,ni.

The elements of sequences are integer numbers from −104−104 to 104104.

The sum of lengths of all given sequences don't exceed 2⋅1052⋅105, i.e. n1+n2+⋯+nk≤2⋅105n1+n2+⋯+nk≤2⋅105.

Output

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≤i≤k,1≤x≤ni), in the third line — two integers jj, yy (1≤j≤k,1≤y≤nj1≤j≤k,1≤y≤nj). 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≠j. You can print them in any order.

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

Examples
input
2
5
2 3 1 3 2
6
1 1 2 2 2 1
output
YES
2 6
1 2
input
3
1
5
5
1 1 1 1 1
2
2 3
output
NO
input
4
6
2 2 2 2 2 2
5
2 2 2 2 2
3
2 2 2
5
2 2 2 2 2
output
YES
2 2
4 1
Note

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.

 #include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + ;
struct node {
int x, y;
node(int x, int y): x(x), y(y) {}
node () {}
bool operator < (node const &a ) const {
return a.x < x;
}
};
map<int,node>mp;
int t, n, a[maxn];
int main() {
scanf("%d", &t);
int flag = ;
for (int k = ; k <= t ; k++) {
scanf("%d", &n);
int sum = ;
for (int i = ; i < n ; i++ ) {
scanf("%d", &a[i]);
sum += a[i];
}
if (flag) continue;
for (int i = ; i < n ; i++) {
int temp = sum - a[i];
if (mp.find(temp) != mp.end()) {
if (mp[temp].x != k) {
printf("YES\n");
printf("%d %d\n", k, i+);
printf("%d %d\n", mp[temp].x, mp[temp].y+);
flag = ;
}
}
if (flag) break;
mp[temp] = node(k, i);
}
}
if (!flag) printf("NO\n");
return ;
}

Equal Sums (map的基本应用) 多学骚操作的更多相关文章

  1. CF 988C Equal Sums 思维 第九题 map

    Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  2. Codeforces Round #486 (Div. 3)-C. Equal Sums

    C. Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  3. 关于map 及 map 骚操作

    关于map这个东西   很冷门..................   但是,这个博客带你稍微了解一下map:   map用法:一般当作一个下表无穷大的数组   关于它的骚操作:map的鬼畜用法,可以 ...

  4. Guava中这些Map的骚操作,让我的代码量减少了50%

    原创:微信公众号 码农参上,欢迎分享,转载请保留出处. Guava是google公司开发的一款Java类库扩展工具包,内含了丰富的API,涵盖了集合.缓存.并发.I/O等多个方面.使用这些API一方面 ...

  5. 闪电侠 Netty 小册里的骚操作

    前言 即使这是一本小册,但基于"不提笔不读书"的理念,仍然有必要总结一下.此小册对于那些"硬杠 Netty 源码 却不曾在千万级生产环境上使用实操"的用户非常有 ...

  6. 通过HTTP的HEADER完成各种骚操作

    作为一名专业的切图工程师,我从来不care网页的header,最多关心Status Code是不是200.但是HEADER真的很重要啊,客户端从服务器端获取内容,首先就是通过HEADER进行各种沟通! ...

  7. python20个骚操作

    Python小白需要知道的 20 个骚操作! Python 是一个解释型语言,可读性与易用性让它越来越热门.正如 Python 之禅中所述: 优美胜于丑陋,明了胜于晦涩. 在你的日常编码中,以下技巧可 ...

  8. Java 12 骚操作, String居然还能这样玩!

    Java 13 都快要来了,12必须跟栈长学起! Java 13 即将发布,新特性必须抢先看! 栈长之前在Java技术栈微信公众号分享过<Java 11 已发布,String 还能这样玩!> ...

  9. Python小白需要知道的 20 个骚操作!

    Python小白需要知道的 20 个骚操作! Python 是一个解释型语言,可读性与易用性让它越来越热门.正如 Python 之禅中所述: 优美胜于丑陋,明了胜于晦涩. 在你的日常编码中,以下技巧可 ...

随机推荐

  1. 在amazon linux上安装Jenkins

    原文请参考: https://medium.com/@itsmattburgess/installing-jenkins-on-amazon-linux-16aaa02c369c

  2. HyperLedger Fabric 1.4 关键技术(6.4)

    本节介绍从最底层的账本开始,逐一讲解账本的结构和存储.智能合约的编写和部署.通道的操作.节点的背书和提交.排序的共识和客户端SDK的接口调用,与交易流程顺序相反,由里及表的说明Fabric最关键的技术 ...

  3. 【Python让生活更美好01】os与shutil模块的常用方法总结

    Python作为一种解释型的高级语言,脚本语言,又被称作“胶水语言”,就是因为其灵活的语法和其依靠浩如烟海的第三方包实现的丰富多彩的功能,而os和shutil就是这样一种功能强大的模块,可以非常快捷地 ...

  4. XML文件中关键字自动提示和不全配置

    一.获得mybatis-3-config.dtd.mybatis-3-mapper.dtd 这两个文件. 建立一个Maven的项目 在Pom.xml文件中的Mybatis jar包的下载设置(也可以从 ...

  5. spring、spring-data-redis整合使用

    一.Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API. 从2010年3月15日起,Redis的开发工作由VMwa ...

  6. Django-modelfrom组件

    ModelForm     a.  class Meta:             model,                           # 对应Model的             fi ...

  7. python基础——元组、文件及其它

    Python核心数据类型--元组 元组对象(tuple)是序列,它具有不可改变性,和字符串类似.从语法上讲,它们便在圆括号中,它们支持任意类型.任意嵌套及常见的序列操作. 任意对象的有序集合:与字符串 ...

  8. js学习日记-常用正则符号参考

    预定义类 量词 贪婪.惰性.支配性量词 前瞻 边界 RegExp是全局对象,RegExp.$1...$9是全局属性.当执行任意正则表达式匹配操作时,JavaScript会自动更新全局对象RegExp上 ...

  9. quartz 使用总结

    quartz是一个任务调度框架,具体的用途比如说,我想我的程序在每天的3点干什么事,每隔多长时间做一件什么事.quartz框架就可以完美地解决这些. 1.xml配置方式 首先我是用spring来管理的 ...

  10. pytest 测试报告

    测试报告 运行测试用例后,为了保存结果,我们需要生成测试报告,同时可以把运行的测试报告发送相关人员查阅,这时需要安装一个插件(pytest-html) pytest-html插件安装 pip inst ...