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
# AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1843026#1) | |
# [方針] | |
# オイラー閉路を持つ --> 全ての頂点の次数が偶数である | |
# => 奇数次数の頂点に対して、追加コストが最小になるように辺を追加する | |
V, E = map(int, raw_input().split()) | |
INF = 10**9 | |
e = [[INF]*V for i in xrange(V)] | |
deg = [0] * V | |
su = 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
# AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1850894#1) | |
V, E, r = map(int, raw_input().split()) | |
es = [map(int, raw_input().split()) for i in xrange(E)] | |
# 以下を参考にさせていただきました | |
# http://ti2236.hatenablog.com/entry/2012/12/07/175841 | |
# Chu-Liu/Edmonds' Algorithm | |
# 最小全域有向木を再帰的に求める | |
# V: 頂点数, es: 辺集合, r: 根となる頂点番号 |
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
// AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1852309) | |
#include<iostream> | |
#include<string> | |
#include<vector> | |
#include<queue> | |
#include<stack> | |
#include<map> | |
#include<set> | |
#include<algorithm> | |
#include<functional> |
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
// AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1867905#1) | |
#include<iostream> | |
#include<string> | |
#include<vector> | |
#include<queue> | |
#include<stack> | |
#include<map> | |
#include<set> | |
#include<algorithm> | |
#include<functional> |
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
// AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1867998) | |
// 方針 | |
// 1. 閉路で何回も見れるやつを見つけるために強連結成分分解して、閉路の頂点を1頂点としてまとめる | |
// 2. DAGとして繋がっているそれらの頂点をDFSで探索しながら個数制約付きナップサック問題として計算していく | |
// (計算する際、まとめた頂点に1つの頂点しか含まれず、自己辺を含まない場合は高々一回しか見れないことに注意する) | |
#include<iostream> | |
#include<string> | |
#include<vector> | |
#include<queue> | |
#include<stack> |
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
" .vimrc settings without plugin | |
scriptencoding utf-8 | |
"" editor | |
" tabをshiftに置き換え | |
" tab幅4を想定した記述 | |
set smarttab | |
set tabstop=4 | |
set shiftwidth=4 | |
set expandtab |
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<bits/stdc++.h> | |
using namespace std; | |
void solve(int n){ | |
vector<long long> a(n); | |
for(int i=0;i<n;i++) cin>>a[i]; | |
long long ans = 3000000; | |
for(int i=0;i<n;i++){ | |
for(int j=i+1;j<n;j++){ | |
ans = min(ans,abs(a[i]-a[j])); |
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
# AC (http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1893746#1) | |
# P(x1, y1), Q(x2, y2)が通る直線上にR(x, y)を写像した先をSとする | |
# r = (x-x1, y-y1), p = (x2-x1, y2-y1) とすると、Sの座標は(x1, y1) + a*pで表される | |
# この時、a = |r|cosθ/|p|で計算できる | |
# この値は内積を利用し、|r||p|cosθ = r・p → |r|cosθ/|p| = r・p / |p|^2 で計算すると楽 | |
from math import sqrt | |
x1, y1, x2, y2 = map(int, raw_input().split()) | |
dx = x2 - x1 | |
dy = y2 - y1 | |
for i in xrange(input()): |
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
# encoding: utf-8 | |
# a Calculus of Communicating System(CCS)に関して、 | |
# プロセスの関係を判定するために書いたプログラム | |
# たぶんあってる | |
import random | |
random.seed() | |
randint = random.randint | |
# τ(プロセスの内部action)をプロセス生成に含めるか(ここでは't'で表現) | |
tau = True |
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
# encoding: utf-8 | |
import random, itertools | |
random.seed() | |
randint = random.randint | |
choice = random.choice | |
shuffle = random.shuffle | |
# n変数によるm個のclauseから成る論理式Fを生成 | |
def make(n, m): |