From 7b77a1216e7d8298d42890463f5b4c73fa54e9ba Mon Sep 17 00:00:00 2001 From: Licsber Date: Sat, 9 Apr 2022 01:07:54 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E7=BB=83=E4=B9=A0=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/Algorithm.iml | 8 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 ++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ lanqiao/__init__.py | 0 lanqiao/main.py | 4 ++ lanqiao/test/2019省最短路-所有路.py | 55 +++++++++++++++++ lanqiao/test/2019省最短路.py | 59 +++++++++++++++++++ lanqiao/test/2020省单词分析.py | 18 ++++++ lanqiao/test/2020省回文日期.py | 24 ++++++++ lanqiao/test/__init__.py | 0 13 files changed, 200 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Algorithm.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 lanqiao/__init__.py create mode 100644 lanqiao/main.py create mode 100644 lanqiao/test/2019省最短路-所有路.py create mode 100644 lanqiao/test/2019省最短路.py create mode 100644 lanqiao/test/2020省单词分析.py create mode 100644 lanqiao/test/2020省回文日期.py create mode 100644 lanqiao/test/__init__.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/Algorithm.iml b/.idea/Algorithm.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/Algorithm.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0be4620 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lanqiao/__init__.py b/lanqiao/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lanqiao/main.py b/lanqiao/main.py new file mode 100644 index 0000000..4e842ec --- /dev/null +++ b/lanqiao/main.py @@ -0,0 +1,4 @@ +import io +import sys + +sys.stdin = io.StringIO('lanqiao') diff --git a/lanqiao/test/2019省最短路-所有路.py b/lanqiao/test/2019省最短路-所有路.py new file mode 100644 index 0000000..089b2ed --- /dev/null +++ b/lanqiao/test/2019省最短路-所有路.py @@ -0,0 +1,55 @@ +map_in = [ + ['A', 'E', 1], + ['A', 'B', 2], + ['A', 'C', 1], + ['A', 'D', 1], + ['A', 'E', 1], + ['B', 'G', 1], + ['B', 'J', 2], + ['C', 'D', 3], + ['C', 'G', 3], + ['C', 'F', 3], + ['D', 'G', 2], + ['D', 'H', 1], + ['D', 'I', 2], + ['E', 'H', 1], + ['E', 'I', 3], + ['F', 'J', 1], + ['F', 'G', 1], + ['G', 'K', 2], + ['G', 'I', 3], + ['H', 'L', 2], + ['H', 'I', 1], + ['I', 'M', 3], + ['J', 'S', 2], + ['K', 'N', 1], + ['K', 'L', 3], + ['L', 'R', 1], + ['L', 'M', 1], + ['M', 'N', 2], + ['M', 'Q', 1], + ['M', 'S', 1], + ['N', 'P', 1], + ['Q', 'O', 1], + ['O', 'R', 3], + ['P', 'O', 1], + ['R', 'S', 1], +] + + +def dp(now_dis, next_node): + for src, dst, dis in map_in: + if src == next_node: + now_dis += dis + if dst == 'S': + ans.append(now_dis) + else: + dp(now_dis, dst) + + +ans = [] +for src, dst, dis in map_in: + if src == 'A': + dp(dis, dst) + +print(min(ans)) diff --git a/lanqiao/test/2019省最短路.py b/lanqiao/test/2019省最短路.py new file mode 100644 index 0000000..2b660c2 --- /dev/null +++ b/lanqiao/test/2019省最短路.py @@ -0,0 +1,59 @@ +map_in = [ + ['A', 'E', 1], + ['A', 'B', 2], + ['A', 'C', 1], + ['A', 'D', 1], + ['A', 'E', 1], + ['B', 'G', 1], + ['B', 'J', 2], + ['C', 'D', 3], + ['C', 'G', 3], + ['C', 'F', 3], + ['D', 'G', 2], + ['D', 'H', 1], + ['D', 'I', 2], + ['E', 'H', 1], + ['E', 'I', 3], + ['F', 'J', 1], + ['F', 'G', 1], + ['G', 'K', 2], + ['G', 'I', 3], + ['H', 'L', 2], + ['H', 'I', 1], + ['I', 'M', 3], + ['J', 'S', 2], + ['K', 'N', 1], + ['K', 'L', 3], + ['L', 'R', 1], + ['L', 'M', 1], + ['M', 'N', 2], + ['M', 'Q', 1], + ['M', 'S', 1], + ['N', 'P', 1], + ['Q', 'O', 1], + ['O', 'R', 3], + ['P', 'O', 1], + ['R', 'S', 1], +] + +# 点的数量 数出来的 +n = 19 +# 初始化图 到自身到距离为0 +fig = [[float('inf')] * n for _ in range(n)] +for i in range(n): + fig[i][i] = 0 + +# 构建好路 每个节点之间的距离 +for src, dst, dis in map_in: + src, dst = ord(src) - ord('A'), ord(dst) - ord('A') + fig[src][dst] = fig[dst][src] = dis + +# 从起点到每个节点到距离 S为最后一个节点 因为是字母序排序的 +dis = [float('inf')] * n +dis[0] = 0 +for i in range(n): + for j in range(n): + dis[j] = min(dis[j], dis[i] + fig[i][j]) + +print(dis) +print(dis[-1]) diff --git a/lanqiao/test/2020省单词分析.py b/lanqiao/test/2020省单词分析.py new file mode 100644 index 0000000..d5778ff --- /dev/null +++ b/lanqiao/test/2020省单词分析.py @@ -0,0 +1,18 @@ +import io +import sys + +sys.stdin = io.StringIO('lanqiao') + +s_in = input() +counter = [0] * 26 +count_max = 0 +for ch in s_in: + idx = ord(ch) - ord('a') + counter[idx] += 1 + count_max = max(count_max, counter[idx]) + +for i in range(26): + if count_max == counter[i]: + print(chr(i + ord('a'))) + print(count_max) + break diff --git a/lanqiao/test/2020省回文日期.py b/lanqiao/test/2020省回文日期.py new file mode 100644 index 0000000..c7cc2b6 --- /dev/null +++ b/lanqiao/test/2020省回文日期.py @@ -0,0 +1,24 @@ +import io +import sys + +sys.stdin = io.StringIO('20200202') + +import datetime + +s_in = input() +year, month, day = int(s_in[:4]), int(s_in[4:6]), int(s_in[-2:]) +now = datetime.date(year, month, day) +one_day = datetime.timedelta(days=1) + +reverse = True +while True: + now += one_day + s = str(now).replace('-', '') + if reverse and s[::] == s[::-1]: + print(s) + reverse = False + + # ABABBABA + if s[0] == s[2] == s[5] == s[7] and s[1] == s[3] == s[4] == s[6]: + print(s) + break diff --git a/lanqiao/test/__init__.py b/lanqiao/test/__init__.py new file mode 100644 index 0000000..e69de29