Skip to content

Instantly share code, notes, and snippets.

@koyumeishi
koyumeishi / sa_bench.cpp
Created November 7, 2023 18:55
焼き鈍しの受理式のベンチマーク
#include <string>
#define NDEBUG
#include <cassert>
#include <chrono>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <random>
@koyumeishi
koyumeishi / AHC001.md
Created March 14, 2021 13:04
AHC 001 のメモ

AHC 001

https://atcoder.jp/contests/ahc001

概要

N個の長方形を 10000x10000 グリッド上に配置せよ

  • 各長方形には必ず含まないといけないセルが1つずつ指定されている
  • 重なっちゃいけない
  • 指定セルに重複はない
@koyumeishi
koyumeishi / readme.md
Created January 30, 2020 21:44
MM114 SnakeCharmer

MM114 SnakeCharmer

概要

  • N*N のグリッド (N は奇数)
  • (floor(N/2), floor(N/2)) のセルからヘビが出てくる
  • ヘビは長さ NN で、頭..尾 を (0..NN-1) の離散的なパーツと考える
  • ヘビの頭(パーツ 0)は今いるセルに隣接するセル (上下左右) へ移動できる。 頭以外のパーツ i は パーツ i-1 があった場所へ移動する
  • ヘビは自分自身と重なったりグリッドの外へ出てはいけない
  • ヘビのパーツにはそれぞれ数が割り当てられている。 S[i] := パーツ i の数 (2<= S[i] <= 9)
  • ヘビが停止したときセル (x,y) に数字 z が書かれたパーツがあるとき、
@koyumeishi
koyumeishi / vis.py
Created February 26, 2019 08:23
visualizer hokudai-hitachi-2018
import numpy as np
import matplotlib.pyplot as plt
import argparse
def read_output(file_name):
with open(file_name) as f:
vars, terms = map(int, f.readline().split())
res = []
for _ in range(terms):
@koyumeishi
koyumeishi / PointsOnGrid.py
Last active February 1, 2019 15:25
mm107 PointsOnGrid IP Solver
from __future__ import print_function
from ortools.linear_solver import pywraplp
from functools import reduce
import sys
import time
class PointsOnGrid:
def findSolution(self, H, W, h, w, Kmin, Kmax, grid):
solver = pywraplp.Solver('SolveIntegerProblem',
pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
while now < timeLimit {
blocks[] = splitBoard( rand( maxBlockSize ) ); // 適当な大きさに分割
for block in blocks{ // それぞれのブロックに対して焼きなます
for i in 0...SAIteration { // SAIteration 回 見ます
cell = nextCell(block) // ナイト置く / 取る位置
flip(cell) // 実際にはスコア計算するだけで flip しない
if accept(i, nextState) { // 焼き鈍し A。 invalid な状態も許容。 i が大きいときはペナルティを大きく
state = nextState // 状態を更新。 これは invalid かも知れない
@koyumeishi
koyumeishi / readme.md
Created June 20, 2018 15:52
TCO18 MM R2 CrystalLighting

CrystalLighting

問題文

順位表

概要

[10,100]^2 のセルに crystal, obstacle が存在する。
3色の lantern を設置して crystal を指定された色で照らせ

@koyumeishi
koyumeishi / test.cpp
Created April 18, 2015 22:31
gist testing
#include <iostream>
using namespace std;
int main(){
cout << "test" << endl;
return 0;
}