From 825fdedaa07b188308ce8ccd6987ff170bdcd0cf Mon Sep 17 00:00:00 2001 From: erickk1212 <148313041+erickk1212@users.noreply.github.com> Date: Thu, 22 May 2025 00:59:03 +0900 Subject: [PATCH 1/2] Update 10775.cpp --- Appendix D/solutions/10775.cpp | 54 +++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/Appendix D/solutions/10775.cpp b/Appendix D/solutions/10775.cpp index 6c991660..915f54ba 100644 --- a/Appendix D/solutions/10775.cpp +++ b/Appendix D/solutions/10775.cpp @@ -1,11 +1,51 @@ -// Authored by : BaaaaaaaaaaarkingDog +// Authored by : erick12(BOJ)/Erickk1212(Github) // Co-authored by : - -// http://boj.kr/**************** -#include +// http://boj.kr/53c3baf12cb8446699fe398d0b171654 +#include using namespace std; - -int main(void){ +int parent[100000]; +int find(int x) +{ + if (x == parent[x]) return x; + return parent[x] = find(parent[x]); +} +void dounion(int x, int y) +{ + x = find(x); + y = find(y); + if (x != y) parent[x] = y; +} +void unionfindsetup(int x) +{ + for (int i = 0; i <= x; i++) + { + parent[i] = i; + } +} +int n, m; +int main() +{ ios::sync_with_stdio(0); cin.tie(0); - -} \ No newline at end of file + cin >> n >> m; + for (int i = 1; i <= n; i++) + { + parent[i] = i; + } + int t = 0; + int ans = m; + for (int i = 0; i < m; i++) + { + int num; + cin >> num; + t = find(num); + if (t == 0) + { + ans = i; + break; + } + parent[t] = t - 1; + } + cout << ans; + return 0; +} From cd4066bf48452cf487a9636246db152bc5377c7b Mon Sep 17 00:00:00 2001 From: erickk1212 <148313041+erickk1212@users.noreply.github.com> Date: Thu, 22 May 2025 01:15:09 +0900 Subject: [PATCH 2/2] Update 10775.cpp --- Appendix D/solutions/10775.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Appendix D/solutions/10775.cpp b/Appendix D/solutions/10775.cpp index 915f54ba..1c4360bd 100644 --- a/Appendix D/solutions/10775.cpp +++ b/Appendix D/solutions/10775.cpp @@ -1,6 +1,6 @@ // Authored by : erick12(BOJ)/Erickk1212(Github) // Co-authored by : - -// http://boj.kr/53c3baf12cb8446699fe398d0b171654 +// http://boj.kr/80ae0844bf6e44558f48685b94f1dfd1 #include using namespace std; int parent[100000];