Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
gzshawnliang committed Apr 8, 2019
1 parent 741e246 commit f638412
Show file tree
Hide file tree
Showing 5 changed files with 27,676 additions and 17 deletions.
2 changes: 1 addition & 1 deletion myCpps/!-OJcreater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using namespace std;

//***************************************
const string CPPfile = "internetBandwidth_UVA820"; //*
const string CPPfile = "softwareAllocation_UVA259"; //*
//***************************************

ifstream fin(CPPfile + ".cpp");
Expand Down
18 changes: 6 additions & 12 deletions myCpps/softwareAllocation_UVA259.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using namespace std;
ifstream fin("softwareAllocation_UVA259.in");
ofstream fout("softwareAllocation_UVA259.out");

const int n = 40;
const int n = 40, inf = INT_MAX / 2;
const string trans2 = "sABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789e";

int trans1(char ch)
Expand All @@ -28,7 +28,7 @@ int trans1(char ch)
}
}

int solve(int start, int end, vector<bool> & visit, vector<char> & computer, vector<vector<int>> & a, vector<vector<int>> & g)
int solve(int start, int end, vector<bool> & visit, vector<char> & computer, vector<vector<int>> & a)
{
int n = a.size() - 1;

Expand Down Expand Up @@ -71,11 +71,8 @@ int solve(int start, int end, vector<bool> & visit, vector<char> & computer, vec
return _min;
}

int size = g[u].size();
for (int i = 0; i <= size - 1; ++i)
for (int v = 0; v <= 37; ++v)
{
int v = g[u][i];

if (a[u][v] <= 0 || visit[v] == true) continue;

visit[v] = true;
Expand All @@ -93,7 +90,7 @@ int main()
{
bool _end = true;
int total = 0;
vector<vector<int>> a(n, vector<int>(n, 0)), g(n);
vector<vector<int>> a(n, vector<int>(n, 0));

// fout << trans1('s') << ' ' << trans1('e');
// for (char ch = 'A'; ch <= 'Z'; ++ch) fout << ' ' << trans1(ch);
Expand All @@ -110,15 +107,12 @@ int main()
_end = false;

a[trans1('s')][trans1(in[0])] = (in[1] - '0');
g[trans1('s')].push_back(trans1(in[0]));
total += (in[1] - '0');

for (int i = 3; in[i] != ';'; ++i)
{
if (a[trans1(in[0])][trans1(in[i])] == 0) g[trans1(in[0])].push_back(trans1(in[i]));
a[trans1(in[0])][trans1(in[i])] = 1;
a[trans1(in[0])][trans1(in[i])] = inf;

if (a[trans1(in[i])][trans1('e')] == 0) g[trans1(in[i])].push_back(trans1('e'));
a[trans1(in[i])][trans1('e')] = 1;
}
}
Expand All @@ -131,7 +125,7 @@ int main()

while (true)
{
int res = solve(trans1('s'), trans1('e'), visit, computer, a, g);
int res = solve(trans1('s'), trans1('e'), visit, computer, a);
if (res == -1)
{
break;
Expand Down
Loading

0 comments on commit f638412

Please sign in to comment.