Skip to content

Instantly share code, notes, and snippets.

@Strikeskids
Strikeskids / pppiv_solver.ml
Created May 4, 2021 18:24
Solver for PlaidCTF 2021: Plaid Party Planning IV
open! Core_kernel
open Pppiv_lib
module Element = struct
type t =
{ person_id : Person_id.t
; game_id : Game_id.t
; score : float
}
[@@deriving sexp_of, compare]
@Strikeskids
Strikeskids / Makefile
Created April 19, 2020 22:15
PlaidCTF 2020 golf.so: server source
all: runso
runso: LDLIBS += -lseccomp
.PHONY: all
@Strikeskids
Strikeskids / .block
Last active September 24, 2019 01:38
hexagonal flower poisson-disc
license: gpl-3.0
// ==UserScript==
// @name Gradescope Keyboard Shortcuts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Keyboard shortcuts to make grading faster.
// @author Strikeskids
// @match https://www.gradescope.com/*grade
// @grant none
// ==/UserScript==
#!/usr/bin/env python
# Written by Strikeskids
from __future__ import print_function
from pwn import *
from time import sleep
import random, string, pickle
from copy import deepcopy
from hashlib import md5
@Strikeskids
Strikeskids / Icpc.java
Created February 21, 2018 23:26
Template for writing ACM ICPC solutions in Java
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Icpc {
public static void main(String... args) throws Exception {

The basic steps are listed below. They are described in more detail afterwards.

  1. Update master
  2. Use a work branch
  3. Clean up your work before sharing
  4. Pull request so that people get notified (or merge)
  5. Clean up your workspace to start again

When doing work, always make sure to update and checkout a new branch. This way, we keep the main branch clean.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/mathjs/1.2.0/math.js"></script>
<style id="jsbin-css">
#source {
display: none;
}
while True:
cmd = raw_input()
noprint =False
noexec =False
if cmd[0]=='x':
noprint=True
if cmd[0]=='p':
noexec=True
if not noexec:
<h1 id="binary-indexed-trees-and-segment-trees">Binary Indexed Trees and Segment Trees</h1>
<h2 id="the-problem">The Problem</h2>
<p>We want to have a data structure that allows us to do two things</p>
<ol>
<li>Make queries of the form <code>f(a[i], ..., a[j])</code> for <code>i &lt;= j</code> (the <strong>query</strong>)</li>
<li>Update <code>a[i] = v</code> for some <code>i</code> (the <strong>update</strong>)</li>
</ol>
<p>Naively, one could do this in such a way that either the query or the update is <code>O(1)</code> and the other is <code>O(n)</code>. The most basic method would be to simply store <code>a[i]</code> and then for the query, simply compute the function in <code>O(n)</code>. However, that will obviously not be good enough for practical applications. </p>
<h2 id="segment-trees">Segment Trees</h2>
<p>Segment trees provide a way to efficiently and easily perform both the query and the update in <code>O(log n)</code>. The key to how this works is that the cumulative totals are stored in a tree