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
#include <map> | |
#include <utility> | |
#include <vector> | |
#include <algorithm> | |
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
typedef long long ll; |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"math" | |
"strconv" | |
"strings" | |
) |
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
{ | |
"size": 0, | |
"query": { | |
"bool": { | |
"must": [ | |
{ "exists": {"field": "status" } }, | |
{ "exists": {"field": "class_name" } }, | |
{ "exists": {"field": "test_name" } } | |
] | |
} |
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
def circle_check(graph): | |
n = len(graph) | |
graph = [list(node.keys()) for node in graph] | |
indexes = [0] * n | |
stack = [0] | |
visited = [False] * n | |
visited[0] = True | |
while stack: | |
curr = stack[-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
MOD = 10 ** 9 + 7 | |
def modpow(x, y, mod): | |
elems = [] | |
while y: | |
elems.append(y % 2) | |
y >>= 1 | |
el = len(elems) | |
x_pows = [x for _ in xrange(el)] |
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
MOD = 10 ** 9 + 7 | |
LEFT, RIGHT = range(2) | |
def modpow(x, y, mod): | |
elems = [] | |
while y: | |
elems.append(y % 2) | |
y >>= 1 | |
el = len(elems) |
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 collections import defaultdict as dd | |
from itertools import product | |
# 2SAT linear solver START | |
def strongly_connected(graph): | |
""" From Cormen: Strongly connected components chapter. """ | |
l = len(graph) | |
normal = [list(graph[i]) for i in xrange(l)] | |
reverse = [[] for _ in xrange(l)] |
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 collections import defaultdict as dd | |
# 2SAT linear solver START | |
def strongly_connected(graph): | |
""" From Cormen: Strongly connected components chapter. """ | |
l = len(graph) | |
normal = [list(graph[i]) for i in xrange(l)] | |
reverse = [[] for _ in xrange(l)] | |
for fr, tos in enumerate(normal): |
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 collections import defaultdict as dd | |
def fill(distances, was, backlinks, top, curr, dist): | |
distances[curr] = dist | |
was[curr] = True | |
while dist > 0: | |
distances[curr] = dist | |
was[curr] = True | |
curr = backlinks[curr][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 random import choice | |
import sys | |
t = int(raw_input().strip()) | |
LOW, HIGH = 0.005, 0.1 | |
def calc(p, count, curr, left): | |
return pow(p, count) * pow(1.0 - p, curr - count) * pow(1.0 - p, left) | |
for case in xrange(1, t + 1): |