From 9ff6f7364193bfe37ddbff18b7335708da0d3a83 Mon Sep 17 00:00:00 2001 From: Yeonsoo <127713796+sooooscode@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:00:08 +0900 Subject: [PATCH 1/5] Create 15685.cpp --- .../15685.cpp" | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 "13_\354\265\234\353\213\250\352\262\275\353\241\234/15685.cpp" diff --git "a/13_\354\265\234\353\213\250\352\262\275\353\241\234/15685.cpp" "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/15685.cpp" new file mode 100644 index 0000000..f43621f --- /dev/null +++ "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/15685.cpp" @@ -0,0 +1,65 @@ +//13_최단경로 필수 1번:15685.cpp + +#include +#include + +using namespace std; + +bool map[101][101] = {false}; +int dx[] = {1, 0, -1, 0}; +int dy[] = {0, -1, 0, 1}; +int ans = 0; + +void dragonCurve(int x, int y, int d, int g); + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + int n; + cin >> n; + + for (int i = 0; i < n; i++) + { + int x, y, d, g; + cin >> x >> y >> d >> g; + dragonCurve(x, y, d, g); + } + + for (int i = 0; i < 100; i++) + { + for (int j = 0; j < 100; j++) + { + if (map[i][j] && map[i][j + 1] && map[i + 1][j] && map[i + 1][j + 1]) + { + ans++; + } + } + } + + cout << ans << "\n"; + + return 0; +} + +void dragonCurve(int x, int y, int d, int g) +{ + vector d_list; + d_list.push_back(d); + + for (int i = 1; i <= g; i++) + { + for (int j = d_list.size() - 1; j >= 0; j--) { + d_list.push_back((d_list[j] + 1) % 4); + } + } + + map[y][x] = true; + for (int direction : d_list) + { + x += dx[direction]; + y += dy[direction]; + map[y][x] = true; + } +} From dc1b1386a31c9c49410c79806bbf22205ad39ad9 Mon Sep 17 00:00:00 2001 From: Yeonsoo <127713796+sooooscode@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:09:36 +0900 Subject: [PATCH 2/5] Create 1238.cpp --- .../1238.cpp" | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 "13_\354\265\234\353\213\250\352\262\275\353\241\234/1238.cpp" diff --git "a/13_\354\265\234\353\213\250\352\262\275\353\241\234/1238.cpp" "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/1238.cpp" new file mode 100644 index 0000000..092b77f --- /dev/null +++ "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/1238.cpp" @@ -0,0 +1,74 @@ +//13_최단경로 필수 2번:1238.cpp + +#include +#include +#include +#include + +using namespace std; + +const int INF = INT_MAX; + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + + int v, e, x; + cin >> v >> e >> x; + + vector>> graph(v + 1); + + for (int i = 0; i < e; ++i) + { + int a, b, cost; + cin >> a >> b >> cost; + graph[a].emplace_back(b, cost); + } + + auto dijkstra = [&](int start) + { + priority_queue, vector>, greater>> pq; + vector distance(v + 1, INF); + + pq.push({0, start}); + distance[start] = 0; + + while (!pq.empty()) + { + int dist = pq.top().first; + int now = pq.top().second; + pq.pop(); + + if (distance[now] < dist) continue; + + for (const auto& edge : graph[now]) + { + int node_index = edge.first; + int node_cost = edge.second; + int cost = dist + node_cost; + + if (distance[node_index] > cost) + { + distance[node_index] = cost; + pq.push({cost, node_index}); + } + } + } + + return distance; + }; + + int result = 0; + + for (int i = 1; i <= v; ++i) + { + vector go = dijkstra(i); + vector back = dijkstra(x); + result = max(result, go[x] + back[i]); + } + + cout << result << "\n"; + + return 0; +} From 22fd3d44e751f1b7f8e6176120aeb46f61713e87 Mon Sep 17 00:00:00 2001 From: Yeonsoo <127713796+sooooscode@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:13:51 +0900 Subject: [PATCH 3/5] Create 2458.cpp --- .../2458.cpp" | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 "13_\354\265\234\353\213\250\352\262\275\353\241\234/2458.cpp" diff --git "a/13_\354\265\234\353\213\250\352\262\275\353\241\234/2458.cpp" "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/2458.cpp" new file mode 100644 index 0000000..c0fbdf5 --- /dev/null +++ "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/2458.cpp" @@ -0,0 +1,58 @@ +//13_필수3: 2458.cpp + +#include +#include +#include + +using namespace std; + +const int INF = 999999999; + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + + int n, m; + cin >> n >> m; + + vector> dist(n + 1, vector(n + 1, INF)); + + for (int i = 1; i <= m; ++i) + { + int a, b; + cin >> a >> b; + dist[a][b] = 1; + } + + for (int k = 1; k <= n; ++k) + { + for (int i = 1; i <= n; ++i) + { + for (int j = 1; j <= n; ++j) + { + dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); + } + } + } + + int ans = 0; + + for (int i = 1; i <= n; ++i) + { + int cnt = 0; + + for (int j = 1; j <= n; ++j) + { + if (dist[i][j] != INF || dist[j][i] != INF) { + cnt++; + } + } + + if (cnt == n - 1) ans++; + } + + cout << ans << "\n"; + + return 0; +} From 7a7964234b5b5ec73322afce679fe7514911a284 Mon Sep 17 00:00:00 2001 From: Yeonsoo <127713796+sooooscode@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:15:37 +0900 Subject: [PATCH 4/5] =?UTF-8?q?Create=20=ED=95=A9=EC=8A=B9=ED=83=9D?= =?UTF-8?q?=EC=8B=9C=EC=9A=94=EA=B8=88.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\212\271\355\203\235\354\213\234\354\232\224\352\270\210.cpp" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "13_\354\265\234\353\213\250\352\262\275\353\241\234/\355\225\251\354\212\271\355\203\235\354\213\234\354\232\224\352\270\210.cpp" diff --git "a/13_\354\265\234\353\213\250\352\262\275\353\241\234/\355\225\251\354\212\271\355\203\235\354\213\234\354\232\224\352\270\210.cpp" "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/\355\225\251\354\212\271\355\203\235\354\213\234\354\232\224\352\270\210.cpp" new file mode 100644 index 0000000..53408cd --- /dev/null +++ "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/\355\225\251\354\212\271\355\203\235\354\213\234\354\232\224\352\270\210.cpp" @@ -0,0 +1 @@ +//13_최단경로 도전 1번:합승택시요금.cpp From 77b6bfb18549007465dcab763b4c64c3bec3d7a8 Mon Sep 17 00:00:00 2001 From: Yeonsoo <127713796+sooooscode@users.noreply.github.com> Date: Wed, 29 Nov 2023 16:15:57 +0900 Subject: [PATCH 5/5] Create 1865.cpp --- "13_\354\265\234\353\213\250\352\262\275\353\241\234/1865.cpp" | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 "13_\354\265\234\353\213\250\352\262\275\353\241\234/1865.cpp" diff --git "a/13_\354\265\234\353\213\250\352\262\275\353\241\234/1865.cpp" "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/1865.cpp" new file mode 100644 index 0000000..d48135d --- /dev/null +++ "b/13_\354\265\234\353\213\250\352\262\275\353\241\234/1865.cpp" @@ -0,0 +1,2 @@ +//13_최단경로 도전 2번:1865.cpp +