解析:
把不同的类型分到一个组里面,然后直接爆搜每一种状态记录最大值即可
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100;
inline int read(){int sgn = 1; int cnt = 0; char ch = getchar();while (ch < '0' || ch > '9') { if(ch == '-')sgn = -sgn;ch = getchar();}while ('0' <= ch && ch <= '9') {cnt = cnt*10 + (ch-'0');ch = getchar();}return sgn*cnt;
}
struct node
{int a,b,c,d;
};
vector<node> v[100];
unordered_map<int,int> mp;
int t,n,k;
ll mx;
int cnt;int ti,ai,bi,ci,di;
void dfs(int u,ll ai,ll bi,ll ci,ll di)
{if(u==cnt){mx=max(mx,(100ll+ai)*(100ll+bi)*(100ll+ci)*(100ll+di));return ;}for(auto x:v[u]){dfs(u+1,ai+x.a,bi+x.b,ci+x.c,di+x.d);}
}
int main()
{t=read();while(t--){n=read();k=read();cnt=1;for(int i=0;i<100;i++) v[i].clear();mx=0;mp.clear();for(int i=1;i<=n;i++){ti=read();ai=read();bi=read();ci=read();di=read();if(!mp[ti]){v[cnt].push_back({ai,bi,ci,di});mp[ti]=cnt;cnt++;} else v[mp[ti]].push_back({ai,bi,ci,di});}dfs(1,0,0,0,0);printf("%lld\n",mx);}
}