This file contains hidden or 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
import sys | |
import math | |
from functools import cache | |
@cache | |
def de_bruijn_bits(n): | |
k = 2 | |
a = [0] * k * n | |
sequence = [0] |
This file contains hidden or 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
from enum import IntEnum, auto | |
from urllib.request import urlopen | |
import lzma | |
import json | |
class DamageType(IntEnum): | |
Impact = 0 | |
Puncture = auto() | |
Slash = auto() | |
Heat = auto() |
This file contains hidden or 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
const readline = require("readline"); | |
const RESET = "\x1b[0m"; | |
const REVERSE = "\x1b[7m"; | |
const LIGHT = "#"; | |
const DARK = "."; | |
const GOAL_STATE = 1; | |
const GRID_WIDTH = +process.argv[2] || 10; | |
const GRID_HEIGHT = +process.argv[3] || GRID_WIDTH; |
This file contains hidden or 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
v=2.26;a=Math.round(v*100);b=100;while(a%=b)[a,b]=[b,a];[Math.round(100/b*v),100/b] |
This file contains hidden or 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
import requests | |
import math | |
import sys | |
import time | |
import ctypes | |
from functools import reduce | |
kernel32 = ctypes.windll.kernel32 | |
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) |
This file contains hidden or 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
//どう足掻いてもテストケースがタイムアウトするしにたい | |
class Node { | |
constructor(data, next = null) { | |
this.data = data; | |
this.next = next; | |
} | |
} | |
let lines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n"); | |
const [N, M, Q] = lines[0].split(" ").map(Number); |
This file contains hidden or 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
lines = require('fs').readFileSync("/dev/stdin", "utf8").split`\n`; | |
const N = +lines[0]; | |
const CARDS = lines.slice(1).map(Number); | |
let count = 0; | |
for (let i = 0; i < N-2; i++) { | |
for (let j = i+1; j < N-1; j++) { | |
for (let k = j+1; k < N; k++) { | |
if ((CARDS[i] + CARDS[j] + CARDS[k]) % 7 === 0) { | |
count++; |
This file contains hidden or 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
lines = require('fs').readFileSync("/dev/stdin", "utf8").split`\n`; | |
const [M, N] = lines[0].split` `.map(Number); | |
let world = lines.slice(1, N+1).map(v => v.split` `.map(Number)); | |
let count = 0; | |
const sinkIsland = sinkIslandEx.bind(null, M, N); | |
for (let y = 0; y < N; y++) { | |
for (let x = 0; x < M; x++) { | |
if (world[y][x] === 1) { |
This file contains hidden or 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
import math, wave, struct | |
def gen(c, duration, pause, volume): | |
S = "123A456B789C?0#D" | |
L = [697, 770, 852, 941] | |
H = [1209, 1336, 1477, 1633] | |
idx = S.find(c) | |
lo, hi = L[idx // 4], H[idx % 4] | |
s1 = [math.sin(2.0 * math.pi * lo * t / 44100) for t in range(int(44100 * duration))] | |
s2 = [math.sin(2.0 * math.pi * hi * t / 44100) for t in range(int(44100 * duration))] |
This file contains hidden or 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
let lines = require("fs").readFileSync("/dev/stdin", "utf8").split`\n`; | |
const [N, M] = lines[0].split` `.map(Number); | |
const S = lines.slice(1, M+1).map(v => v.split` `.map(v => +v-1)); | |
const gathering = start => { | |
let found = [start]; | |
const f = start => { | |
for (let v of vertices[start]) { | |
if (found.includes(v)) { | |
continue; |
NewerOlder