Skip to content

Instantly share code, notes, and snippets.

View SansPapyrus683's full-sized avatar
😀
a minor inconvenience

Kevin Sheng SansPapyrus683

😀
a minor inconvenience
View GitHub Profile
@SansPapyrus683
SansPapyrus683 / day15.rs
Created April 26, 2024 03:24
incomplete advent of code 2018 day 15
use itertools::Itertools;
use std::collections::{HashMap, HashSet, VecDeque};
use std::fs;
fn neighbors(r: usize, c: usize) -> Vec<(usize, usize)> {
let (ir, ic) = (r as i32, c as i32);
vec![(ir + 1, ic), (ir - 1, ic), (ir, ic + 1), (ir, ic - 1)]
.iter()
.filter(|(r, c)| *r >= 0 && *c >= 0)
.map(|(r, c)| (*r as usize, *c as usize))
@SansPapyrus683
SansPapyrus683 / playground.py
Last active November 11, 2024 14:57
download all your twitter anime girls!
import os
import shutil
def parse_id(tweet: str) -> str:
start = tweet.rfind("_") - 1
res = ""
while tweet[start] != "_":
res = tweet[start] + res
start -= 1
@SansPapyrus683
SansPapyrus683 / suff_arr.cpp
Created January 15, 2024 03:07
Suffix Array Implementation
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using std::cout;
using std::endl;
using std::vector;
using std::string;
@SansPapyrus683
SansPapyrus683 / .gitconfig
Last active October 26, 2024 23:56
some config files (linux and windows)
[user]
name = Kevin Sheng
email = [email protected]
[credential]
helper = store
[core]
editor = nvim
[pull]
rebase = true
[push]
@SansPapyrus683
SansPapyrus683 / conventions.md
Last active August 1, 2023 10:54
code conventions to satisfy dustin

general code stuff

  • comments
    • inline comments should be two spaces after the line of code
    • if a single comment takes over two lines, use a multiline comment
  • sols should have nearly the same structure, same names, etc. to avoid confusion
  • avoid global variables
  • for the brace languages, always use braces & space em out like: for (int i = 0; i < 2; i++) {
  • an if-else should be like this:
@SansPapyrus683
SansPapyrus683 / LCATree.java
Last active June 7, 2024 00:28
Tree with LCA capabilities (C++ and Java)
import java.util.*;
/** Tree class with LCA capabilities and some other handy functions. */
public class LCATree {
private final int[] par;
private final int[][] pow2Ends;
private final int[] depth;
private final int log2Dist;
/**
@SansPapyrus683
SansPapyrus683 / drought_gold.md
Last active August 9, 2023 09:47
Solution for "Drought" (2022 USACO Gold)

bro i could passed gold lmao
i actually knew how to solve 2 problems

but anyways, here's the gold p1 editorial on request (actual problem here, i won't bother explaining it myself, just read the darn thing)

so it would be absolute cancer to try and actually calculate if each tuple can get to a level where all cows have the same hunger level
not only that, calculating all the possible tuples themselves...

@SansPapyrus683
SansPapyrus683 / kruznice.md
Created January 28, 2022 05:39
Solution for "KRUZNICE"

so yknow i was on the dp grind when someone posted this problem on the github issues for the usaco guide (you can test here, but prepare google translate)

so we have a buncha circles, intervals really
and we wanna remove some so that none of them intersect (they can be tangent tho)

so let's define min_remove[s][e] as the minimum amount of circles we have to remove given that the only circles we consider are the ones that are completely

@SansPapyrus683
SansPapyrus683 / game_master.md
Created January 16, 2022 01:24
solution for game master on cf

"Domination". Look it up.

— Scout, TF2

after the dec contest, i have come to the conclusion that i suck a** at dp
so i was grinding cf and i came upon this problem that had the tag dp
but my solution was anything but that, so lemme just share my sol

@SansPapyrus683
SansPapyrus683 / hilo.md
Created December 29, 2021 17:46
Solution for "HILO" (2021 USACO Gold)

hi
december contest ptsd again
this problem again

since the problem explanation is too complicated, i'll just let you read the problem yourself, there's no way i'm going to explain it myself

ok i'll assume you read the thing

anyway just the first thing i did was write a brute force python script to