# Untitled

unknown
plain_text
2 years ago
2.3 kB
1
Indexable
Never
```#include <bits/stdc++.h>
#define int int64_t

using namespace std;

vector<vector<int>> v;

int32_t main() {
int k;
cin >> k;
for (int i = 0; i < k; i++) {
int n;
cin >> n;
v.emplace_back();
for (int j = 0; j < n; j++) {
int x;
cin >> x;
v[i].push_back(x);
}
}
for (int i = 0; i < k; i++) {
for (int j = 0; j < k; j++) {
if (i == j)
continue;
for (int l = 0; l < k; l++) {
if (l == j || l == i)
continue;
for (auto a : v[i]) {
auto it2 = lower_bound(v[j].begin(), v[j].end(), a);

int b = 1e14;

if (it2 != v[j].end()) {
b = *it2;
}
if  (it2-- != v[j].begin() && abs(a - b) > abs(a - *it2 )) {
b = *it2;
}

auto it = lower_bound(v[l].begin(), v[l].end(), min(a, b));
if (it != v[l].end() && 2 * max({a, b, *it}) < a + b + *it) {
cout << i + 1 << ' ' << a << ' ' << j + 1 << ' ' << b << ' ' << l + 1 << ' ' << *it;
return 0;
}
if (it-- != v[l].begin() && 2 * max({a, b, *it}) < a + b + *it) {
cout << i + 1 << ' ' << a << ' ' << j + 1 << ' ' << b << ' ' << l + 1 << ' ' << *it;
return 0;
}
it = lower_bound(v[l].begin(), v[l].end(), max(a, b));
if (it != v[l].end() && 2 * max({a, b, *it}) < a + b + *it) {
cout << i + 1 << ' ' << a << ' ' << j + 1 << ' ' << b << ' ' << l + 1 << ' ' << *it;
return 0;
}
if (it-- != v[l].begin() && 2 * max({a, b, *it}) < a + b + *it) {
cout << i + 1 << ' ' << a << ' ' << j + 1 << ' ' << b << ' ' << l + 1 << ' ' << *it;
return 0;
}
}
}
}
}
cout << -1;
}
```