Created
May 11, 2015 18:16
-
-
Save balamark/2a2dbcbd513c4fb49791 to your computer and use it in GitHub Desktop.
SRM 144 div2 1000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctime> | |
#include <iostream> | |
#include <algorithm> | |
#include <set> | |
#include <vector> | |
#include <sstream> | |
#include <typeinfo> | |
#include <fstream> | |
#include <utility> | |
#include <cstring> | |
using namespace std; | |
const int N=50; | |
class PowerOutage { | |
public: | |
int g[N][N]; | |
int aux[N]; | |
int dfs(int s){ | |
int res = 0; | |
for (int i = 0; i < N; ++i){ | |
if(g[s][i]!=-1){ | |
res = max(res, dfs(i)+g[s][i]); | |
} | |
} | |
return res; | |
} | |
int estimateTimeOut(vector<int> fromJunction, vector<int> toJunction, vector<int> ductLength) { | |
int sz=fromJunction.size(); | |
memset(g, -1, sizeof(g)); | |
int tot=0; | |
for(int i=0;i<sz;++i){ | |
g[fromJunction[i]][toJunction[i]]=ductLength[i]; | |
tot += 2*ductLength[i]; | |
} | |
return tot-dfs(0); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment