提交记录 33792
| 提交时间 |
评测时间 |
| 2026-08-14 22:35:13 |
2026-08-14 22:35:20 |
#include <stdio.h>
#include <string.h>
#define INF 0x3f3f3f3f
int g[13][13]; int n, m;
int dp[1<<12][13];
int main(){
scanf("%d%d", &n, &m);
memset(g, 0x3f, sizeof(g));
for(int i=0;i<m;i++){ int u,v,w; scanf("%d%d%d",&u,&v,&w); u--;v--; if(w<g[u][v]) g[u][v]=g[v][u]=w; }
int full = (1<<n)-1; int ans = INF;
for(int root=0; root<n; root++){
memset(dp, 0x3f, sizeof(dp));
dp[1<<root][0] = 0;
for(int mask=1; mask<=full; mask++){
for(int d=0; d<n; d++){
if(dp[mask][d] >= INF) continue;
int rest = full ^ mask;
for(int sub=rest; sub; sub=(sub-1)&rest){
int c=0, ok=1, v;
for(v=0; v<n; v++) if(sub>>v & 1){
int mn=INF, u;
for(u=0; u<n; u++) if((mask>>u & 1) && g[u][v] < mn) mn=g[u][v];
if(mn>=INF){ ok=0; break; }
c += mn;
}
if(!ok) continue;
int nm = mask|sub; int nc = dp[mask][d] + c*(d+1);
if(nc < dp[nm][d+1]) dp[nm][d+1] = nc;
}
}
}
int d; for(d=0; d<n; d++) if(dp[full][d] < ans) ans = dp[full][d];
}
printf("%d\n", ans);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 29.42 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #2 | 54.85 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #3 | 136.83 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #4 | 264.66 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #5 | 777.55 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #6 | 425 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #7 | 122.86 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #8 | 408.97 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #9 | 112.08 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #10 | 158.56 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #11 | 479.89 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #12 | 471.83 us | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #13 | 1.794 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #14 | 1.789 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #15 | 111.087 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #16 | 112.006 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #17 | 392.476 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #18 | 439.858 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #19 | 445.086 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #20 | 447.354 ms | 224 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-09-09 13:00:59 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠