Submission #1865811
Source Code Expand
#include <bits/stdc++.h> using namespace std; inline int gi(){ char ch=getchar();int x=0,q=0; while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar(); while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar(); return q?(-x):x; } int f[35000][17],w[35000],c[17][17]; void dp(int &x,int y){ if (x<y) x=y; return; } int main(){ int n=gi(),m=gi(),z,a,b,p,S=(1<<n)-1,d=0; for (int i=1; i<=m; ++i){ a=gi(),b=gi(),p=gi(); c[a][b]+=p,c[b][a]+=p; z=(1<<(a-1))|(1<<(b-1)); for (int s=1; s<(1<<n); ++s) if ((s&z)==z) w[s]+=p; d+=p; } memset(f,-100,sizeof(f)); f[1][1]=0; for (int s=1; s<=S; ++s) for (int i=1; i<=n; ++i) if (s&(1<<(i-1))){ for (int j=1; j<=n; ++j) if (!(s&(1<<(j-1)))&&c[i][j]) dp(f[s|(1<<(j-1))][j],f[s][i]+c[i][j]); for (int t=S^s; t; t=(t-1)&(S^s)) dp(f[s|t][i],f[s][i]+w[t|1<<(i-1)]); } int ans=0; for (int s=1; s<=S; ++s) dp(ans,f[s][n]); cout<<d-ans; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Mole and Abandoned Mine |
User | Thefinal |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 998 Byte |
Status | AC |
Exec Time | 183 ms |
Memory | 2688 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 900 / 900 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 3 ms | 2560 KB |
00_example_02.txt | AC | 3 ms | 2560 KB |
00_example_03.txt | AC | 179 ms | 2688 KB |
01.txt | AC | 182 ms | 2688 KB |
02.txt | AC | 4 ms | 2560 KB |
03.txt | AC | 3 ms | 2560 KB |
04.txt | AC | 3 ms | 2560 KB |
05.txt | AC | 3 ms | 2560 KB |
06.txt | AC | 3 ms | 2560 KB |
07.txt | AC | 3 ms | 2560 KB |
08.txt | AC | 56 ms | 2688 KB |
09.txt | AC | 3 ms | 2560 KB |
10.txt | AC | 3 ms | 2560 KB |
11.txt | AC | 182 ms | 2688 KB |
12.txt | AC | 179 ms | 2688 KB |
13.txt | AC | 182 ms | 2688 KB |
14.txt | AC | 183 ms | 2688 KB |
15.txt | AC | 183 ms | 2688 KB |
16.txt | AC | 183 ms | 2688 KB |
17.txt | AC | 182 ms | 2688 KB |
18.txt | AC | 180 ms | 2688 KB |
19.txt | AC | 181 ms | 2688 KB |
20.txt | AC | 182 ms | 2688 KB |
21.txt | AC | 179 ms | 2688 KB |
22.txt | AC | 179 ms | 2688 KB |
23.txt | AC | 181 ms | 2688 KB |
24.txt | AC | 180 ms | 2688 KB |
25.txt | AC | 178 ms | 2688 KB |