This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decrypt_session(cookie) { | |
const SALT = "authenticated encrypted cookie"; | |
const secret = crypto.pbkdf2Sync(secret_key_base, SALT, 1000, 32, 'sha1'); | |
const [data, iv, auth_tag] = cookie.split('--').map(s => Buffer.from(s, 'base64')); | |
const decipher = crypto.createDecipheriv('aes-256-gcm', secret, iv); | |
decipher.setAuthTag(auth_tag); | |
let decrypted_data = decipher.update(data); | |
decrypted_data = Buffer.concat([decrypted_data, decipher.final()]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "xxx" | |
version = "0.1.0" | |
edition = "2021" | |
[profile.release] | |
opt-level = 3 | |
debug = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use svg::{ | |
node::{ | |
self, | |
element::{path::Data, Path, Text}, | |
}, | |
Document, | |
}; | |
const WIDTH: f64 = 70.0; | |
const STROKE_WIDTH: f64 = 0.6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::read_to_string; | |
use chrono::{DateTime, FixedOffset, NaiveDate, TimeZone, Utc}; | |
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | |
#[derive(Debug)] | |
struct RawEvent { | |
start: Option<DateTime<FixedOffset>>, | |
end: Option<DateTime<FixedOffset>>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::Result; | |
use reqwest::ClientBuilder; | |
use scraper::{Html, Selector}; | |
use serde::Deserialize; | |
use std::collections::{HashMap, HashSet}; | |
#[tokio::main] | |
async fn main() -> Result<()> { | |
let client = ClientBuilder::new().gzip(true).build()?; | |
let cookie = "..."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::Result; | |
use reqwest::ClientBuilder; | |
use serde::Deserialize; | |
use std::collections::{HashMap, HashSet}; | |
#[tokio::main] | |
async fn main() -> Result<()> { | |
let client = ClientBuilder::new().gzip(true).build()?; | |
let models: HashMap<String, ProblemModel> = client | |
.get("https://kenkoooo.com/atcoder/resources/problem-models.json") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
# Topcoder MM の実行可能ファイルのパス | |
# 一時ファイルは /workdir に置くといいらしい | |
TEMP_PATH="/workdir/a.out" | |
rm -f submission.zip | |
cargo clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to | |
# compress e. g. bookmark backups (*.jsonlz4). | |
# | |
# This file format is in fact just plain LZ4 data with a custom header (magic number [8 bytes] and | |
# uncompressed file size [4 bytes, little endian]). | |
# | |
# This Python 3 script requires the LZ4 bindings for Python, see: https://pypi.python.org/pypi/lz4 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 切った後の長方形の数 = 切り分けた線分の数 + 1 なので、線分の数を数えることにする。 | |
- 線分は周囲に3つのブロックがある格子点を端点に持っている。 | |
- 周囲に3つのブロックがある格子点を凹点と呼ぶことにする。 | |
- 全てのピースが長方形であるということは凹点が存在しないということ。 | |
- 線分の数は凹点の数でおさえられる。 | |
- 凹点同士を結ぶ線分が多ければ多いほどよい。 | |
- 線分の数 = 凹点の数 - 凹点同士を結ぶ線分の数 | |
- 凹点同士を結ぶ線分を1本引くと2つの凹点を潰すことが出来るため | |
- 凹点同士を結ぶ線分を2本交わるように引いても4つの凹点を潰したことにはならない。 | |
- 1本目の線分を引いた時点で多角形が切り分けられ、2本目は凹点同士を結ぶ線分にならない。 |
NewerOlder