Skip to content

Instantly share code, notes, and snippets.

💭
💻

Joona Yoon joonas-yoon

💭
💻
Block or report user

Report or block joonas-yoon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joonas-yoon
joonas-yoon / boj-5052-trie.cpp
Created Feb 23, 2020
BOJ 5052 - 전화번호 목록 (Trie)
View boj-5052-trie.cpp
#include <cstdio>
struct node {
node(char data = 0) {
isLeaf = false;
links = 0;
for (int i = 0; i < 10; ++i) link[i] = 0;
}
int links;
node* link[10];
@joonas-yoon
joonas-yoon / boj-5052-sort.cpp
Last active Feb 23, 2020
BOJ 5052 - 전화번호 목록 (정렬)
View boj-5052-sort.cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
int T, n, i;
cin >> T;
while(T--){
cin >> n;
string s;
vector<string> v(n);
@joonas-yoon
joonas-yoon / swea-7673.cpp
Created Feb 22, 2020
SWEA 7673 - 영이는 영이 시져시져!
View swea-7673.cpp
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long lld;
const int INF = 0x3f3f3f3f;
struct cell {
View heap.cpp
////////////////////////////////////////////
// @title Implement of Min-Heap
// @author Joonas <joonas.yoon@gmail.com>
// @blog https://joonas.tistory.com
////////////////////////////////////////////
#define MAX_SIZE 100001
template <typename T>
class MinHeap {
@joonas-yoon
joonas-yoon / str_to_int-3.cpp
Last active Feb 21, 2020
hashing string to unique integer + padding (it can be compare)
View str_to_int-3.cpp
#define MAX_LENGTH 13
unsigned long long MAX_LENGTH_VALUE; // 꽤 큰 값은 리터럴 상수 선언이 안되는 것 같다.
unsigned long long str2llu(const char s[MAX_LENGTH + 1]) {
unsigned long long r = 0, x = MAX_LENGTH_VALUE;
for (int i = 0; s[i]; ++i) {
r += x * (s[i] - 'a' + 1LLU);
x /= 27;
}
@joonas-yoon
joonas-yoon / str_to_int-base26.cpp
Last active Feb 21, 2020
hashing string to unique integer - base 26
View str_to_int-base26.cpp
#define MAX_LENGTH 13
unsigned long long str2llu(const char s[MAX_LENGTH + 1]) {
unsigned long long r = 0;
for (int i = 0; s[i]; ++i) r = r * 26 + s[i] - 'a';
return r;
}
@joonas-yoon
joonas-yoon / str_to_int-2.cpp
Last active Feb 21, 2020
hashing string to unique integer + padding (it can be compare)
View str_to_int-2.cpp
#define MAX_LENGTH 13
unsigned long long str2llu(const char s[MAX_LENGTH + 1]) {
unsigned long long r = 0;
int i = 0;
for (; s[i]; ++i) r = r * 27 + s[i] - 'a' + 1;
for (; i < MAX_LENGTH; ++i) r = r * 27; // 길이가 동일하도록 패딩(padding) 해준다.
return r;
}
@joonas-yoon
joonas-yoon / str_to_int.cpp
Last active Feb 21, 2020
hashing string to unique integer
View str_to_int.cpp
#define MAX_LENGTH 13
unsigned long long str2llu(const char s[MAX_LENGTH + 1]) {
unsigned long long r = 0;
for (int i = 0; s[i]; ++i) r = r * 27 + s[i] - 'a' + 1;
return r;
}
View moving_average.py
def moving_average(a):
ma = a[0]
for i in range(1, len(a)):
ma = ma*i/(i+1) + a[i]/(i+1)
return ma
if __name__ == "__main__":
a = [3,1,4,1,5,9,2,6,5,3,5,8]
print("Avg.:", sum(a)/len(a))
@joonas-yoon
joonas-yoon / boj-5535.cpp
Created Jan 2, 2020
BOJ 5535 - 패셔니스타
View boj-5535.cpp
#include <cstdio>
#include <cstring> // memset
#include <vector>
#include <algorithm> // std::max
using namespace std;
int D, N;
int d[201], dp[201][201];
vector<int> adj[201];
You can’t perform that action at this time.