Git Product home page Git Product logo

boj's Introduction

BOJ Preset

Python3

# 빠른 입력 받기
from sys import stdin, stdout
a = int(stdin.readline())
# 빠른 입력 받기 (한 줄에 여러개, int)
from sys import stdin, stdout
a, b, c = map(int, stdin.readline().split())
# 빠른 출력
from sys import stdin, stdout
stdout.write(f"{a} {b}\n")
# for 인덱스와 값 동시 출력
from sys import stdin, stdout
list = []
for idx, val in enumerate(list):
    stdout.write(f"{idx} {val}\n")
# n 줄을 입력 받고 배열에 저장
from sys import stdin, stdout
n = int(stdin.readline())
data = [stdin.readline().strip() for _ in range(n)]
# 정렬 (람다 활용)
list = [[21, 'Junkyu'], [21, 'Dohyun'], [20, 'Sunyoung']]
list.sort(key=lambda x: x[0])
# 퀵 정렬
def Partition(array, low, high):
  pivot = array[high]
  i = low - 1
  for j in range(low, high):
    if array[j] <= pivot:
      i = i + 1
      (array[i], array[j]) = (array[j], array[i])
  (array[i + 1], array[high]) = (array[high], array[i + 1])
  return i + 1

def Quick_Sort(array, low, high):
  if low < high:
    pi = Partition(array, low, high)
    Quick_Sort(array, low, pi - 1)
    Quick_Sort(array, pi + 1, high)
# 이분 탐색
def Binary_Search(array, target, start, end):
    if start >= end:
        return -1
    mid = (start + end) // 2
    if array[mid] == target:
        return mid
    elif array[mid] > target:
        return Binary_Search(array, target, start, mid - 1)
    else:
        return Binary_Search(array, target, mid + 1, end)

Binary_Search(array, target, start, end - 1)
# 최소힙과 최대힙을 사용해 최소값과 최대값 찾기
import heapq

def kth_smallest(nums, k):
  heap = []
  for num in nums:
    heapq.heappush(heap, num)

  kth_min = None
  for _ in range(k):
    kth_min = heapq.heappop(heap)
  return kth_min

print(kth_smallest([4, 1, 7, 3, 8, 5], 3))
# 힙 정렬
import heapq

def heap_sort(nums):
  heap = []
  for num in nums:
    heapq.heappush(heap, num)

  sorted_nums = []
  while heap:
    sorted_nums.append(heapq.heappop(heap))
  return sorted_nums

print(heap_sort([4, 1, 7, 3, 8, 5]))
# 캐시
from functools import cache
@cache
# 데이터 미리 입력
from sys import stdin, stdout
import io

stdin = io.StringIO("""3 1 2""")

N, R, C = map(int, stdin.readline().split())

C++

#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a;
    cin >> a;
}

boj's People

Contributors

lif-lee avatar

Stargazers

리리리프 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.