AcWing 3779. 相等的和

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <cstdio>
#include <unordered_map>
using namespace std;
using PII = pair<int, int>;
const int N = 200001;
int k, n, a[N], s;
unordered_map<int, PII> m;
int main() {
scanf("%d", &k);
for (int i = 1; i <= k; ++i) {
scanf("%d", &n);
s = 0;
for (int j = 1; j <= n; ++j) {
scanf("%d", &a[j]);
s += a[j];
}
for (int j = 1; j <= n; ++j) {
int t = s - a[j];
if (m.count(t) && m[t].first != i) {
puts("YES");
printf("%d %d\n", m[t].first, m[t].second);
printf("%d %d\n", i, j);
return 0;
}
m[t] = {i, j};
}
}
puts("NO");
return 0;
}