Wed, 30 Jan 2019 13:15:07 GMT
parent
79294a03e3
commit
29a5a1cd72
@ -1,12 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
set(CMAKE_CXX_FLAGS "/Zc:__cplusplus")
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.2.1\\x86_64-w64-mingw32")
|
||||
add_executable("A" "A.cpp")
|
||||
add_executable("B" "B.cpp")
|
||||
add_executable("C" "C.cpp")
|
||||
add_executable("D" "D.cpp")
|
||||
add_executable("E" "E.cpp")
|
||||
add_executable("F" "F.cpp")
|
||||
add_executable("G" "G.cpp")
|
||||
add_executable("Z" "Z.cpp")
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if(MSVC)
|
||||
add_compile_options("/Zc:__cplusplus")
|
||||
endif()
|
||||
include_directories("C:\\Programs\\GCC\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32")
|
||||
add_executable(A A.cpp)
|
||||
add_executable(B B.cpp)
|
||||
add_executable(C C.cpp)
|
||||
add_executable(D D.cpp)
|
||||
add_executable(E E.cpp)
|
||||
add_executable(F F.cpp)
|
||||
add_executable(G G.cpp)
|
||||
add_executable(H H.cpp)
|
||||
add_executable(I I.cpp)
|
||||
add_executable(J J.cpp)
|
||||
add_executable(K K.cpp)
|
||||
add_executable(L L.cpp)
|
||||
add_executable(M M.cpp)
|
||||
add_executable(N N.cpp)
|
||||
add_executable(O O.cpp)
|
||||
add_executable(P P.cpp)
|
||||
add_executable(Q Q.cpp)
|
||||
add_executable(R R.cpp)
|
||||
add_executable(S S.cpp)
|
||||
add_executable(T T.cpp)
|
||||
add_executable(U U.cpp)
|
||||
add_executable(V V.cpp)
|
||||
@ -0,0 +1,67 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
unordered_map<string, int> m;
|
||||
int getId(const char *str)
|
||||
{
|
||||
auto ite = m.find(str);
|
||||
if (ite != m.end())
|
||||
return ite->second;
|
||||
else
|
||||
return m[str] = m.size();
|
||||
}
|
||||
const int N = 20050;
|
||||
int adj[N], nxt[N], to[N], len[N], dis[N], ecnt;
|
||||
inline void addEdge(int f, int t, int l)
|
||||
{
|
||||
ecnt++;
|
||||
nxt[ecnt] = adj[f];
|
||||
adj[f] = ecnt;
|
||||
to[ecnt] = t;
|
||||
len[ecnt] = l;
|
||||
}
|
||||
inline void rst()
|
||||
{
|
||||
m.clear();
|
||||
ecnt = 0;
|
||||
memset(adj, 0, sizeof(adj));
|
||||
memset(dis, 0x3f3f3f3f, sizeof(dis));
|
||||
}
|
||||
char buf1[50], buf2[50];
|
||||
struct node
|
||||
{
|
||||
int u, w;
|
||||
};
|
||||
bool operator<(const node x, const node y) noexcept { return x.w > y.w; }
|
||||
priority_queue<node> h;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while (scanf("%d", &n), ~n)
|
||||
{
|
||||
rst();
|
||||
scanf("%s%s", buf1, buf2);
|
||||
int S = getId(buf1), T = getId(buf2);
|
||||
for (int i = 0, x, y, z; i < n; i++)
|
||||
{
|
||||
scanf("%s%s%d", buf1, buf2, &z);
|
||||
x = getId(buf1), y = getId(buf2);
|
||||
addEdge(x, y, z), addEdge(y, x, z);
|
||||
}
|
||||
dis[S] = 0;
|
||||
h.push({S, dis[S]});
|
||||
while (!h.empty())
|
||||
{
|
||||
auto u = h.top().u, w = h.top().w;
|
||||
h.pop();
|
||||
if (w != dis[u]) continue;
|
||||
for (int e = adj[u]; e; e = nxt[e])
|
||||
if (dis[to[e]] > w + len[e])
|
||||
dis[to[e]] = w + len[e], h.push({to[e], dis[to[e]]});
|
||||
}
|
||||
if (dis[T] > 15000) dis[T] = -1;
|
||||
printf("%d\n", dis[T]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue