| id | source | title | author |
|---|---|---|---|
problemID |
CF |
Problem Name |
Your Name |
| import sys | |
| import zipfile | |
| from pathlib import Path | |
| import os | |
| import shutil | |
| path = sys.argv[1] | |
| extract_to = Path(path).stem | |
| with zipfile.ZipFile(path, 'r') as zip_ref: | |
| os.makedirs(extract_to) |
| 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)) |
| import json | |
| import os | |
| import re | |
| import shutil | |
| import sys | |
| from datetime import datetime, timedelta | |
| from email import utils | |
| import requests |
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| #include <algorithm> | |
| using std::cout; | |
| using std::endl; | |
| using std::vector; | |
| using std::string; |
| [user] | |
| name = Kevin Sheng | |
| email = [email protected] | |
| [credential] | |
| helper = store | |
| [core] | |
| editor = nvim | |
| [pull] | |
| rebase = true | |
| [push] |
- 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:
| 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; | |
| /** |
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...
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