Skip to content

Instantly share code, notes, and snippets.

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

SansPapyrus683 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 / .vimrc
Last active March 28, 2024 04:27
some config files (linux and windows)
" https://stackoverflow.com/a/234578/12128483
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab " set expandtab& to just indent w/ tabs
" https://vi.stackexchange.com/a/4250
set softtabstop=4
@SansPapyrus683
SansPapyrus683 / debugging.h
Last active March 17, 2024 02:21
A useful debugging template for C++.
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& vec) {
@SansPapyrus683
SansPapyrus683 / twitter.py
Created February 26, 2024 21:17
download all your twitter anime girls!
import json
import re
import os
import shutil
import requests
def load_twt_obj(file: str) -> list:
raw = open(file).read()
return json.loads(raw[raw.find("=") + 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 / matryoshka.md
Last active January 3, 2024 04:00
Translation for 2016 JOI Matryoshka

Translation credit to Kaz Nakao

You are ordering $N$ matryoshka dolls. They each have a diameter $R$ and a height $H$. A matryoshka doll will only fit inside another if the former's height and width are both strictly less than the latter's.

You also have $Q$ queries. Each of these $Q$ queries has two arguments: $A$ and $B$. For each of the queries, you need to answer the following question: Among the set of dolls that have minimum diameter $A$ and maximum height $B$, how can you fit these dolls in each other, making "towers" of dolls, so that the total number of "towers" is minimal?

@SansPapyrus683
SansPapyrus683 / inheritance.md
Last active January 3, 2024 03:59
Translation for 2015 JOI Inheritance

Translation credit to Kaz Nakao

In the country of IOI, there was a railway mogul JOI that owned all of the railroads.
However, JOI has passed away and the railways he owns are to be distributed as a split inheritance.

In IOI, there are $N$ cities and there are $M$ railroads that connect the cities.
The cities are numbered $1$ to $N$, and the railroads are numbered $1$ to $M$.
A railroad $i$ runs between city $A_i$ and $B_i$ in both directions and generates a distinct profit of $C$ yen.
There may be several lines between the same two cities.

@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 / 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 / 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