본문 바로가기
728x90
반응형

자료구조10

[Atcoder] D - Friends (C++) Problem Problem Statement There are NN persons called Person 11 through Person NN. You are given MM facts that "Person AiAi and Person BiBi are friends." The same fact may be given multiple times. If XX and YY are friends, and YY and ZZ are friends, then XX and ZZ are also friends. There is no friendship that cannot be derived from the MM given facts. Takahashi the evil wants to divide the NN pe.. 2021. 1. 13.
[Codility] Lesson1 - Iterations: BinaryGap app.codility.com/programmers/lessons/1-iterations/ 1. Iterations lesson - Learn to Code - Codility Find longest sequence of zeros in binary representation of an integer. app.codility.com Problem A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary represent.. 2020. 12. 14.
[백준] 1927 : 최소힙 Problem 최소 힙 성공분류 시간 제한메모리 제한제출정답맞은 사람정답 비율 1 초 (추가 시간 없음) 128 MB 17636 7409 5770 46.412% 문제 널리 잘 알려진 자료구조 중 최소 힙이라는 것이 있다. 최소 힙을 이용하여 다음과 같은 연산을 지원하는 프로그램을 작성하시오. 배열에 자연수 x를 넣는다. 배열에서 가장 작은 값을 출력하고, 그 값을 배열에서 제거한다. 프로그램은 처음에 비어있는 배열에서 시작하게 된다. 입력 첫째 줄에 연산의 개수 N(1≤N≤100,000)이 주어진다. 다음 N개의 줄에는 연산에 대한 정보를 나타내는 정수 x가 주어진다. 만약 x가 자연수라면 배열에 x라는 값을 넣는(추가하는) 연산이고, x가 0이라면 배열에서 가장 작은 값을 출력하고 그 값을 배열에서 제.. 2020. 9. 13.
[백준] 2529 : 부등호 How to solve 이 문제는 0~9 의 수 중 각 부등호에 넣을 수 있는 수를 구하는 것이다. 부등호가 성립하도록 넣어지는 수는 중복되지 않는다. ​ Tip1. 순열은 구할 때는, next_permutation() prev_permutation() 함수를 활용해서 구한다. ​ Tip2. 부등호가 성립하는지 확인하는 함수를 만든다. ​ 풀이 순서 본 문제는 다음과 같은 순서로 풀이한다. 1. 순열의 최대 값을 maxVal에 저장한다. 2. maxVal의 순열 값의 부등호 성립여부를 연산하여, 성립하면 return 한다. prev_permutation()으로 이전 순열 값을 찾으며, 1-2 과정을 반복한다. 3. 순열의 최소 값을 minVal에 저장한다. 4. 순열의 최소 값 부터 시작하여 next_p.. 2020. 9. 4.
728x90
반응형