Skip to content

Instantly share code, notes, and snippets.

View kiwiyou's full-sized avatar
🥝

kiwiyou kiwiyou

🥝
View GitHub Profile
@kiwiyou
kiwiyou / csr.py
Created January 20, 2024 03:06
PyPy Compressed Sparse Row
from array import array
class Graph:
def __init__(self, N):
self.h = array('I', [1 << 30]) * N
self.l = array('I')
self.e = array('I')
def connect(self, u, v):
p = self.h[u]
self.h[u] = len(self.l)
@kiwiyou
kiwiyou / main.rs
Last active October 15, 2023 07:34
Simple IO
use std::io::*;
fn solve() {
let mut reader = Reader::new();
let t = reader.read();
for _ in 0..t {
let a: i32 = reader.read();
let b: i32 = reader.read();
println!("{}", a + b);
}
@kiwiyou
kiwiyou / script.js
Created April 23, 2023 04:58
BOJ Group Practice Tier
// ==UserScript==
// @name BOJ Group Practice Tier
// @namespace Violentmonkey Scripts
// @match https://www.acmicpc.net/group/practice/view/*
// @grant GM_xmlhttpRequest
// @version 1.0
// @author kiwiyou
// ==/UserScript==
const problemAnchors = document.querySelectorAll('a[href^="/problem/"]');
const problemMap = new Map();
@kiwiyou
kiwiyou / splay.rs
Created January 5, 2023 06:54
Splay tree
trait SplayOp {
type T;
fn pull(_t: &mut SplayTree<Self>, _u: usize) {}
fn push(_t: &mut SplayTree<Self>, _u: usize) {}
}
struct SplayNode<T> {
v: T,
c: [u32; 2],
@kiwiyou
kiwiyou / linkcut.rs
Created January 5, 2023 04:48
Link cut tree
trait LinkCutOp {
type T;
fn pull(_t: &mut LinkCutTree<Self>, _u: usize) {}
fn push(_t: &mut LinkCutTree<Self>, _u: usize) {}
}
struct LinkCutNode<T> {
v: T,
c: [u32; 2],
@kiwiyou
kiwiyou / solution.rs
Created August 11, 2022 22:11
Hyper Tomato (BOJ 17114)
use core::mem::MaybeUninit;
use alloc::collections::VecDeque;
use basm::io;
const D: usize = 11;
pub fn main() {
let mut reader = io::Reader::<{ 1 << 15 }>::new();
let mut writer = io::Writer::<32>::new();
let mut tomato: [u8; (1_000_000 + 7) / 8] = unsafe { MaybeUninit::uninit().assume_init() };
@kiwiyou
kiwiyou / script.js
Created September 20, 2021 00:43
Use unicode for rendering Yethangul in Naver Korean dictionary
// ==UserScript==
// @name Naver YetHangul to Unicode
// @namespace Violentmonkey Scripts
// @match https://ko.dict.naver.com/
// @grant none
// @version 1.0
// @author kiwiyou <[email protected]>
// ==/UserScript==
new MutationObserver(e => {
@kiwiyou
kiwiyou / main.rs
Created September 1, 2021 09:11
Rust Fast I/O
fn main() {
let buf = stdin();
let mut token = buf.split_ascii_whitespace();
use std::fmt::Write;
// buf.clear();
let mut buf = String::new();
writeln!(buf, "{}", token.next().unwrap()).unwrap();
print!("{}", buf);
}
@kiwiyou
kiwiyou / schoolpage.py
Created September 22, 2020 15:03
교육청 학급홈페이지 로그인 시스템
import requests
import re
class SchoolPage:
def __init__(self, site_id: str, return_url: str, fail_url: str, session=requests.Session()):
# 로그인 페이지 참조
self.site_id = site_id
self.return_url = return_url
self.fail_url = fail_url
self.reset()
@kiwiyou
kiwiyou / square-interactive.c
Last active July 3, 2020 16:44
draw square interactively
#include <stdio.h>
#include <curses.h>
int sq(int w, int h) {
int x, y = 1;
while (y <= h) {
x = 1;
while (x <= w) {
if ((x == 1 || x == w) && (y == 1 || y == h)) {
addch('o');