https://twitter.com/yfba_/status/948287028415770624
増加列(Judge ver.)
(1, 2, ..., n)の順列pが与えられる。pの広義増加部分列の個数はいくつか。
dp[i]:=the number of increasing subsequence which ends with i-th element とする。遷移はdp[i]=sum(dp[j])+1。ただし、和はj
class BinaryIndexedTree | |
def initialize | |
@N=200_001 | |
@bit=Array.new(@N){0} | |
end | |
def add(k, x) | |
while k<=@N | |
@bit[k]+=x | |
k+=(k&-k) |
class SegmentTree | |
def initialize(n) | |
@root, @nil=0, 0 | |
@sz=2**(Math.log(n)/Math.log(2)).ceil | |
@seg=Array.new(2*@sz-1){@nil} | |
end | |
attr_accessor :seg | |
def max(a, b, i=@root, l=0, r=@sz) |
#include<iostream> | |
#include<vector> | |
using namespace std; | |
#define int long long | |
#define repeat(i,n) for(int i=0;i<(n);i++) | |
struct Median{ | |
int K, k, md; | |
vector<int> prv, nxt; |
void main(){ | |
import std.stdio, std.string, std.conv, std.algorithm; | |
import std.typecons; | |
int x, k; | |
rd(x); rd(k); | |
auto r=readln.split.to!(int[]); | |
alias Q=Tuple!(int, "t", int, "a"); | |
auto qs=new Q[](0); | |
foreach(t; r) qs~=Q(t, -1); |
https://twitter.com/yfba_/status/948287028415770624
増加列(Judge ver.)
(1, 2, ..., n)の順列pが与えられる。pの広義増加部分列の個数はいくつか。
dp[i]:=the number of increasing subsequence which ends with i-th element とする。遷移はdp[i]=sum(dp[j])+1。ただし、和はj
import std.stdio, std.string, std.conv, std.algorithm; | |
import std.exception, std.random, std.typecons, std.math; | |
import std.datetime; | |
auto sw=StopWatch(AutoStart.no); | |
class Problem{ | |
const int N=100; | |
const int Q=1000; | |
const int TL=6000; // ms |
class Sudoku | |
attr_accessor :table | |
def initialize(table) | |
@n, @k = 9, 3 # n=k^2 | |
@table = table | |
end | |
def solve | |
def ok(i, x) # 場所iに数字xを置けるか |
// - Test | |
// dmd mybinaryheap.d -main -unittest [-cov] | |
// ./mybinaryheap | |
// | |
// - import | |
// import mybinaryheap : MyBinaryHeap | |
module mybinaryheap; | |
unittest |
void main() | |
{ | |
import mybinaryheap : MyBinaryHeap; | |
import std.container.binaryheap : BinaryHeap; | |
import std.container.rbtree : RedBlackTree; | |
import std.datetime.stopwatch : benchmark; | |
import std.stdio : writeln; | |
import std.random : Random, unpredictableSeed, uniform; | |
auto rnd = Random(unpredictableSeed); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<title>ABC108/ARC102 D</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.5/svg.js"></script> | |
<script src="./svg.path.js"></script> | |
<link href="https://fonts.googleapis.com/css?family=Inconsolata|Lato:400,400i" rel="stylesheet"> |