This file contains 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 collections | |
class MaxFlow: | |
"""Dinic Algorithm: find max-flow | |
complexity: O(EV^2) | |
used in GRL6A(AOJ) | |
""" | |
class Edge: | |
def __init__(self, to, cap, rev): |
This file contains 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
# -*- coding: utf-8 -*- | |
class Gperm: | |
def countfee(self, x, y): | |
range = xrange | |
N, E = 50, len(x) | |
INF = 10**9 | |
dp = [INF] * (1 << E) | |
dp[0] = 0 | |
edge = [0] * N | |
# 各頂点を塗りつぶさない状態にしたときにコストがかからなくなる枝集合を計算 |
This file contains 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 <bits/stdc++.h> | |
using namespace std; | |
typedef long long int ll; | |
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++) | |
#define REP(i,x) FOR(i,0,x) | |
struct Gperm { | |
vector<int> x, y; | |
int countfee(vector<int> _x, vector<int> _y) { |
This file contains 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 <bits/stdc++.h> | |
using namespace std; | |
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++) | |
#define REP(i,x) FOR(i,0,x) | |
int main() { | |
int Q; scanf("%d", &Q); | |
map<int, int> mult; | |
mult[0]++; |
This file contains 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 <bits/stdc++.h> | |
using namespace std; | |
typedef long long int ll; | |
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++) | |
#define REP(i,x) FOR(i,0,x) | |
int main() { | |
int N; cin >> N; | |
vector<ll> C(N); REP(i, N) cin >> C[i]; |
This file contains 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 <bits/stdc++.h> | |
using namespace std; | |
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++) | |
#define REP(i,x) FOR(i,0,x) | |
#define ALL(c) c.begin(), c.end() | |
int main() { | |
int N; scanf("%d", &N); | |
vector<int> X(N); REP(i, N) scanf("%d", &X[i]); |
This file contains 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 math import hypot | |
a, b = map(int, input().split()) | |
n = int(input()) | |
ans = 10**6 | |
for _ in range(n): | |
x, y, v = map(int, input().split()) | |
ans = min(ans, hypot(x-a, y-b)/v) | |
print('{:.20f}'.format(ans)) |
This file contains 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 fractions import gcd | |
H, W, K = map(int, input().split()) | |
g = gcd(K, W) | |
W, K = W//g, K//g | |
print(K//2*W//2+(K-1)//2*(W-2)//2) |
This file contains 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 strutils, sequtils | |
let | |
tmp = stdin.readline.split.map(parseInt) | |
(N, M) = (tmp[0], tmp[1]) | |
var edge = newSeqWith(N, newSeq[int]()) | |
for _ in 1..M: | |
let | |
e = stdin.readline.split.map(parseInt) | |
(s, t) = (e[0]-1, e[1]-1) | |
edge[t].add(s) |
This file contains 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 strutils, algorithm, sequtils | |
let | |
N = stdin.readline.parseInt | |
A = stdin.readline.split.map(parseInt) | |
var students = newSeq[(int, int)](N) | |
for i, a in A: students[i] = (a, i+1) | |
students.sort(cmp) | |
for student in students.reversed: | |
student[1].echo |