baekjoon 20260406
This commit is contained in:
parent
6a75ad4594
commit
5cfa8774e1
41
code_study/Baekjoon/c/10775.c
Normal file
41
code_study/Baekjoon/c/10775.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define MAX 100000
|
||||||
|
|
||||||
|
int G, P, gi, res;
|
||||||
|
int parent[MAX+1];
|
||||||
|
|
||||||
|
void init_uf();
|
||||||
|
int find(int x);
|
||||||
|
void Union(int x);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
scanf("%d %d", &G, &P);
|
||||||
|
init_uf();
|
||||||
|
|
||||||
|
for(int i=0; i<P; i++) {
|
||||||
|
scanf("%d",&gi);
|
||||||
|
|
||||||
|
if(find(gi) == 0) break;
|
||||||
|
|
||||||
|
Union(gi);
|
||||||
|
res++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d\n", res);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_uf() {
|
||||||
|
for(int i=0; i<=G; i++) parent[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int find(int x) {
|
||||||
|
if(x != parent[x]) return parent[x] = find(parent[x]);
|
||||||
|
return parent[x];
|
||||||
|
}
|
||||||
|
|
||||||
|
void Union(int x) {
|
||||||
|
parent[find(x)] = find(x)-1;
|
||||||
|
}
|
||||||
2
code_study/Baekjoon/python/3047.py
Normal file
2
code_study/Baekjoon/python/3047.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
a = sorted(list(map(int, input().split())))
|
||||||
|
print(*[a[ord(c) - ord('A')] for c in input()])
|
||||||
Loading…
x
Reference in New Issue
Block a user