Skip to content

Instantly share code, notes, and snippets.

View mumumu's full-sized avatar

Yoshinari Takaoka mumumu

View GitHub Profile

https://codeforces.com/contest/1334/problem/A

解説

ゲームの2つの stats - number of play (np) と number of clear (nc) は、以下の条件を すべて 満たさなければならない

  • A) np は単調増加である
  • B) nc は単調増加である
  • C) nc の変化量 は np の変化量以下である

https://codeforces.com/contest/1297/problem/B

区間の重なりを O(C+T) で解く方法として、 いもす法 が知られているが、この問題では T が 10^9 に達するため、いもす法では解くことが出来ない。

この問題で数えるべき「区間の重なりの数が1」の区間は、区間の端っことその前後に属する区間の数を数えることで、O(C^2) で数えることができる。

本番ではいもす法では解けないことを理解していたので、区間を重ねてみて冷静に観察すれば解けた... はずである(´ー`; )

fun oneInRange(arr: ArrayList<Pair<Int, Int>>, pos: Int): Boolean {
import kotlin.math.*
fun main() {
val firstline = readLine()!!.split(" ")
val k = firstline[1].toLong()
val arr = readLine()!!.split(" ").map { it.toLong() }
var pairlist = mutableListOf<Pair<Long, Int>>()
for ((idx, value) in arr.withIndex()) {
pairlist.add(Pair(value, idx))
@mumumu
mumumu / sylpheed_vi_keybind.patch
Last active September 22, 2019 10:56
sylpheed vi keybind patch, highly improved version than previous one ( https://gist.github.com/mumumu/e11837ec1e5923981b7f0b0064259388 )
Index: src/mainwindow.c
===================================================================
--- src/mainwindow.c (revision 3616)
+++ src/mainwindow.c (working copy)
@@ -481,7 +481,9 @@
static void next_labeled_cb (MainWindow *mainwin,
guint action,
GtkWidget *widget);
-
+static void latest_cb (MainWindow *mainwin,

コンテスト名そのものにもリンクを貼ってもらえると嬉しいです。

たとえば 「Codeforces Round #555 (Div. 3)」のテキストに、https://codeforces.com/contest/1157 へのリンクを張るという具合です。

バーチャルコンテストへのリンク (*1) もあるとなお嬉しかったりしますが、UI的に微妙になるかもしれない。。

(*1) https://codeforces.com/contest/1157/virtual

@mumumu
mumumu / vimium_myconf.txt
Created April 3, 2019 01:51
vimium の自己流設定。モード指定など全て無効に
# Insert your preferred key mappings here.
unmapAll
map j scrollDown
map k scrollUp
map l scrollRight
map h scrollLeft
map gg scrollToTop
map G scrollToBottom
@mumumu
mumumu / addTargetBlankattrToAnchor.js
Last active January 25, 2019 10:47
ページ内 a タグを target="_blank" に変えるブックマークレット。今時の # な URL だったら意味無いけどね。
javascript:var elms=document.getElementsByTagName('a');for(var i=0;i<elms.length;i++){elms[i].setAttribute('target','_blank');}

Q. C++ で using namespace std; をなぜ避けるのか?

A. 以下のような、「名前空間汚染」と呼ばれる害悪を引き起こすからです。
特に複数人で、比較的大きなコードを書く場合は強く効いてきます。

ここでは、 std を名前空間の例として挙げていますが、std に限りません。

1. std 名前空間に定義されている名前と被った、ユーザー定義型などを安易に使えなくなる

わざとらしい例だと、以下のような感じです。

Git 版 Courier IMAP をビルドし、起動する方法のメモ

courier-unicode は、以下の方法でビルドし、インストールしておく

$ git clone https://github.com/svarshavchik/courier-libs
$ cd courier-libs/unicode
$ autoheader
$ aclocal
@mumumu
mumumu / couriertls_tls_private_key_memo.md
Last active September 25, 2018 13:24
couriertls の TLS_PRIVATE_KEY 対応方針

couriertls の TLS_PRIVATE_KEY 対応方針

ここでは、下記チケットの対応方針について述べる
svarshavchik/courier#10

前提

couriertls(1) には client モードと server モードがある。

client モードは、 couriertls が TLSクライアントとして動作するときのモードを実装するものである。server モードはその対になるもので、courirertls がサーバとして動作するときのモードを実装するものである。