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 -*- | |
def partition(A, p, r): | |
x = A[r] | |
i = p - 1 | |
for j in range(p, r): | |
# A[j] > xの時は,何もせず,jを増加させるのみ | |
if A[j] <= x: | |
# A[j] <= x(A[j]がx以下の時) |
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
def merge(A, left, mid, right): | |
global cnt | |
L = A[left:mid] + [1000000001] | |
R = A[mid:right] + [1000000001] | |
i = j = 0 | |
for k in range(left, right): | |
if L[i] <= R[j]: | |
A[k] = L[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
# -*- coding: utf-8 -*- | |
import math | |
class KochCurve(object): | |
# public変数 | |
x = 0.0 | |
y = 0.0 | |
# private変数 | |
#__xy = 0.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<cstdio> | |
#include<vector> | |
using namespace std; | |
class ExhaustiveSearch | |
{ | |
public: | |
void solve(int n, int A[], int q, int M[]) | |
{ |
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 ExhaustiveSearch: | |
def solve(self, A, M): | |
for m in M: | |
if self.search(0, m): | |
print("yes") | |
else: | |
print("no") |
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
def check(P): | |
global k, T, n | |
i = 0 | |
for j in range(k): | |
s = 0 | |
while s + T[i] <= P: | |
s += T[i] | |
i += 1 | |
if (i == 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
if __name__ == '__main__': | |
n = int(input()) | |
dic = set() | |
for i in range(n): | |
Cmd, Key = input().split() | |
if Cmd == "insert": | |
dic.add(Key) | |
else: |
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
def binarySearch(A, n, key): | |
left = 0 | |
right = n | |
while (left < right): | |
mid = (left + right) // 2 | |
if (key == A[mid]): | |
return 1 | |
if (key > A[mid]): | |
left = mid + 1 |
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
def linearSearch(A, n, key): | |
i = 0 | |
A.append(key) | |
while (A[i] != key): | |
i += 1 | |
del A[n] | |
return i != 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
# -*- coding: utf-8 -*- | |
if __name__ == '__main__': | |
l = input() | |
S1, S2 = [], [] | |
sum = 0 | |
n = len(l) | |
for i in range(n): |
NewerOlder