Fxzbed 题解分享 · 2024/4/7
组队(结果填空) - 题解
``` #include <bits/stdc++.h> using namespace std; vector<int> sorce[20]; int select[5], maxV; bool ist[20]; void check() { for (int i = 0; i < 5; i ++) cout << select[i] << ' '; puts(""); int tmp = 0; for (int i = 0; i < 5; i ++) { tmp += sorce[select[i]][i]; } maxV = maxV > tmp ? maxV : tmp; return; } void dfs(int u) { if (u == 5) { check(); return; } for (int i = 0; i < 20; i ++) if (!ist[i]) { ist[i] = true; select[u] = i; dfs(u + 1); ist[i] = false; } } int main(void) { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); for (int i = 0; i < 20; i ++) { int idx; cin >> idx; for (int j = 0; j < 5; j ++) { int tmp; cin >> tmp; sorce[i].push_back(tmp); } } dfs(0); cout << maxV; return 0; } ```
查看全文
0 0 1 4
acmer10 题解分享 · 2024/4/4
组队(结果填空) - 题解
``` #include<iostream> #include<cstring> #include<algorithm> using namespace std; #define N 30 typedef struct player{ int a,b,c,d,e; }; player p[N]; bool vis[N]; player path[N]; int sum=0; void dfs(int u) { if(u==6) { sum=max(sum,path[1].a+path[2].b+path[3].c+path[4].d+path[5].e); return ; } for(int i=1;i<=20;i++) { if(!vis[i]) { path[u]=p[i]; vis[i]=true; dfs(u+1); vis[i]=false; } } } int main() { p[1].a=97;p[1].b=90; p[2].a=92;p[2].b=85;p[2].c=96; p[3].d=93; p[4].d=80;p[4].e=86; p[5].a=89;p[5].b=83;p[5].c=97; p[6].a=82;p[6].b=86; p[7].d=87;p[7].e=90; p[8].b=97;p[8].c=96; p[9].c=97; p[10].a=95; p[10].b=99; p[11].c=96;p[11].d=97; p[12].d=93;p[12].e=98; p[13].a=94;p[13].b=91; p[14].b=83;p[14].c=87; p[15].c=98;p[15].d=97;p[15].e=98; p[16].d=93;p[16].e=86; p[17].a=98;p[17].b=83; p[17].c=99; p[17].d=98;p[17].e=81; p[18].a=93;p[18].b=87; p[18].c=92; p[18].d=96;p[18].e=98; p[19].d=89;p[19].e=92; p[20].b=99;p[20].c=96;p[20].d=95;p[20].e=81; dfs(1); cout<<sum<<endl; return 0; } ```
查看全文
0 0 0 2