fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class BridgeBuildingDiv2 {
  5. public:
  6. int minDiameter(vector<int> a, vector<int> b, int k) {
  7. int nd = 0, sz = a.size() + 1;
  8. vector<vector<int> > dp(30, vector<int>(30, 1e9));
  9. for (int i = 0; i < a.size(); i++) {
  10. dp[nd][nd + 1] = dp[nd + 1][nd] = a[i];
  11. dp[nd][nd] = 0;
  12. dp[nd + 1][nd + 1] = 0;
  13.  
  14. ++nd;
  15. }
  16.  
  17. ++nd;
  18. for (int i = 0; i < b.size(); ++i) {
  19. dp[nd][nd + 1] = dp[nd + 1][nd] = b[i];
  20. dp[nd][nd] = 0;
  21. dp[nd + 1][nd + 1] = 0;
  22. ++nd;
  23. }
  24.  
  25. int ans = 1e9;
  26. for (int l = 0; l < (1 << sz); ++l) {
  27. if(__builtin_popcount(l)!=k)continue;
  28. for (int i = 0; i < sz; ++i)
  29. if (l & (1 << i))
  30. dp[i][i + sz] = dp[i + sz][i] = 0;
  31. for (int k = 0; k < sz * 2; ++k)
  32. for (int i = 0; i < sz * 2; ++i)
  33. for (int j = 0; j < sz * 2; ++j)
  34. dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  35. int tmp = 0;
  36. for (int i = 0; i < sz * 2; ++i)
  37. for (int j = 0; j < sz * 2; ++j)
  38. if (dp[i][j] < 1e9)
  39. tmp = max(tmp, dp[i][j]);
  40. ans = min(ans, tmp);
  41. for (int i = 0; i < sz; ++i)
  42. if (l & (1 << i))
  43. dp[i][i + sz] = dp[i + sz][i] = 1e9;
  44. }
  45. return ans;
  46. }
  47. };
  48.  
Compilation error #stdin compilation error #stdout 0s 3136KB
stdin
Standard input is empty
compilation info
/usr/lib/gcc/i586-linux-gnu/4.9/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty