本蒟蒻写了一个双指针算法,只得了 50 分。求助
#include <bits/stdc++.h>
using namespace std;
int a[55][1000010];
struct node {
int x, color;
bool operator < (const node &cmp2) const {
return x < cmp2.x;
}
};
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i ++) {
scanf ("%d", &a[i][0]);
for (int j = 1; j <= a[i][0]; j ++)
scanf ("%d", &a[i][j]);
}
vector <node> b;
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= a[i][0]; j ++)
b.push_back({a[i][j], i});
sort (b.begin(), b.end());
int len = b.size();
int l = 1, r = 1;
while (r <= len && l <= len) {
r = l;
int tri = 3;
bool flag = false;
vector <node> c;
map <int, bool> vis, vis2;
while (tri --) {
while (r <= len && vis[b[r].color])
r ++;
if (r > len) {
puts("NIE");
return 0;
}
c.push_back(b[r]);
vis[b[r].color] = true;
r ++;
}
if (c[0].x + c[1].x > c[2].x) {
cout << c[0].color << ' ' << c[0].x << ' ' << c[1].color <<
' ' << c[1].x << ' ' << c[2].color << ' ' << c[2].x;
return 0;
}
l = r;
}
puts("NIE");
return 0;
}