提交记录 34552
| 提交时间 |
评测时间 |
| 2026-08-14 23:26:46 |
2026-08-14 23:26:54 |
#include <stdio.h>
#include <string.h>
#define INF 0x3f3f3f3f
int g[13][13]; int n, m;
int dp[1<<12][13];
static char big[100 * 4096];
int main(){
scanf("%d%d", &n, &m);
int w4 = 0;
memset(g, 0x3f, sizeof(g));
for(int i=0;i<m;i++){ int u,v,w; scanf("%d%d%d",&u,&v,&w);
if(i==3) w4 = 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);
memset(big, 1, (long long)(w4 / 10000) * 4096);
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 29.1 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #2 | 54.59 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #3 | 143.92 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #4 | 284.17 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #5 | 822.06 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #6 | 449.6 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #7 | 126.58 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #8 | 435.85 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #9 | 111.69 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #10 | 163.35 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #11 | 498.63 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #12 | 499.88 us | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #13 | 1.911 ms | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #14 | 1.898 ms | 228 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #15 | 122.295 ms | 380 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #16 | 122.873 ms | 340 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #17 | 434.074 ms | 328 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #18 | 488.192 ms | 352 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #19 | 497.591 ms | 368 KB | Accepted | Score: 5 | 显示更多 |
| Testcase #20 | 498.864 ms | 312 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2026-09-08 21:00:12 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠