rt 这份代码:
#include <bits/stdc++.h>
using namespace std;
const int M = 1010;
const int N = 500010;
struct Info {
int val, pos;
} maxn[M][M];
int n, opt, ans, x, y, a[N][3];
inline int calc(int x) {
int mn = min({a[x][1], a[x][2], a[x][3]});
return (mn * mn * mn) >> 2;
}
inline int rest(int x, int y) {
if (x == 1 && y == 2) {
return 3;
} else if (x == 1 && y == 3) {
return 2;
} else {
return 1;
}
}
int main(int argc, char const *argv[]) {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 3; j++) {
scanf("%d", a[i] + j);
}
sort(a[i] + 1, a[i] + 3);
if (calc(i) > ans) {
ans = calc(i), x = i;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 3; j++) {
for (int k = j + 1; k <= 3; k++) {
int mx = maxn[a[i][j]][a[i][k]].val;
if (mx == 0) {
continue;
}
int rs = rest(j, k);
a[i][rs] += mx;
if (calc(i) > ans) {
opt = 1, ans = calc(i);
y = i, x = maxn[a[i][j]][a[i][k]].pos;
}
a[i][rs] -= mx;
}
}
for (int j = 1; j <= 3; j++) {
for (int k = j + 1; k <= 3; k++) {
int rs = rest(j, k);
if (maxn[a[i][j]][a[i][k]].val < a[i][rs]) {
maxn[a[i][j]][a[i][k]] = {a[i][rs], i};
}
}
}
}
if (opt == 0) {
printf("0\n%d\n%d\n", x, ans);
} else {
printf("1\n%d %d\n%d\n", min(x, y), max(x, y), ans);
}
return 0;
}
拿了40pts, 但是下载数据发现, 和输出或题解输出一致, 不知道为何WA 求dalao指点