【链接】:CF988C
【题意】:在n个序列中任选两个序列,两个序列都除去他们中的一个数,使的总和相同
【分析】:map
【代码】:
#include <bits/stdc++.h>
using namespace std;
const int N = 2*1e5+5;
int n,m,a[N];
map<int,pair<int,int> > mp;
int main()
{
int n;
int m;
scanf("%d",&n);
for(int j=0;j<n;j++)
{
scanf("%d",&m);
int sum=0;
for(int i=0;i<m;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
//cout<<"sum = "<<sum<<endl;
for(int i=0;i<m;i++)
{
//cout<<"sum-a["<<i+1<<"] = "<<sum-a[i]<<endl;
if(mp.count(sum-a[i]))
{
cout<<"YES"<<endl<<mp[sum-a[i]].first<<' '<<mp[sum-a[i]].second<<endl<<j+1<<' '<<i+1<<endl;
return 0;
}
}
for(int i=0;i<m;i++)
{
mp[sum-a[i]]={j+1,i+1};
//cout<<"mp["<<sum-a[i]<<"]:"<<"j="<<j+1<<' '<<"i="<<i+1<<endl;
}
}
cout<<"NO"<<endl;
}
/*
2
5
2 3 1 3 2
sum = 11
sum-a[1] = 9
sum-a[2] = 8
sum-a[3] = 10
sum-a[4] = 8
sum-a[5] = 9
mp[9]:j=1 i=1
mp[8]:j=1 i=2
mp[10]:j=1 i=3
mp[8]:j=1 i=4
mp[9]:j=1 i=5
6
1 1 2 2 2 1
sum = 9
sum-a[1] = 8
YES
1 4
2 1
*/