Skip to content

Instantly share code, notes, and snippets.

View lishunan246's full-sized avatar
🍥
神楽めあは世界一可愛い

复读机 lishunan246

🍥
神楽めあは世界一可愛い
View GitHub Profile
@lishunan246
lishunan246 / b1045.cpp
Created December 23, 2015 08:15
1045. 快速排序(25)
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
int main()
{
int N;
@lishunan246
lishunan246 / b1048.cpp
Created December 25, 2015 07:46
1048. 数字加密(20)
#include<iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
string A, B;
cin >> A >> B;
@lishunan246
lishunan246 / a1064.cpp
Created January 2, 2016 08:13
1064. Complete Binary Search Tree
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N;
int pos = 0;
int tree[1005];
vector<int> input;
@lishunan246
lishunan246 / Counting_Inversions.py
Created November 20, 2016 15:28
Counting Inversions
f = open("IntegerArray.txt")
a = []
for line in f:
a.append(int(line))
def handle(t1, t2):
a1 = t1
a2 = t2
result = []
@lishunan246
lishunan246 / quicksort.py
Created November 21, 2016 10:40
quicksort
input_file = open("QuickSort.txt")
input_array = []
for line in input_file:
input_array.append(int(line))
def partition(A, l, r):
if r - l <= 0:
return 0
@lishunan246
lishunan246 / kargerMinCut.py
Created November 22, 2016 08:06
Karger's algorithm
import random
smallest = 100000
for t in range(1, 1000):
input_file = open("kargerMinCut.txt")
dic = {}
for line in input_file:
l = line.split('\t')
nums = list(map(lambda x: int(x), l[:len(l) - 1]))
dic[nums[0]] = nums[1:]
#include <iostream>
#include <map>
#include <fstream>
#include <vector>
#include <stack>
#include <algorithm>
std::vector<std::vector<unsigned>> finishOrder;
@lishunan246
lishunan246 / dijkstra.cpp
Created December 1, 2016 11:22
Dijkstra's algorithm
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
void split(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss;
@lishunan246
lishunan246 / median.cpp
Created December 6, 2016 08:50
median maintenance
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
int main()
{
std::ifstream input_file("D:\\Playground\\Median.txt");
std::vector<int> x, m, h1, h2;
@lishunan246
lishunan246 / 2sum.cpp
Created December 7, 2016 17:56
two sum
#include <fstream>
#include <iostream>
#include <unordered_set>
#include <thread>
#include <future>
int foo(long long a, long long b, const std::unordered_set<long long>& set)
{
int result(0);