Skip to content

Instantly share code, notes, and snippets.

View heart4lor's full-sized avatar

Sun Yongfei heart4lor

View GitHub Profile
@heart4lor
heart4lor / process.py
Created August 10, 2019 01:42
selfie2anime processing
import os
from shutil import copyfile
import cv2
def selfie():
base_dir = 'selfie'
train_dir = 'trainA'
if not os.path.exists(train_dir):
os.makedirs(train_dir)
@heart4lor
heart4lor / maze.cpp
Created February 27, 2017 13:24
[first blood] bfs without debug!
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
struct node
{
int x;
@heart4lor
heart4lor / UVa_572_BFS.cpp
Last active February 23, 2017 12:33
[UVa_572] 求连通块 #tags: ACM, DFS, BFS, algorithm
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int m,n;
int dir[8][2] = {{-1,0},{-1,1},{0,1},{1,1},
{ 1,0},{1,-1},{0,-1},{-1,-1}};
bool vis[105][105];
char map[105][105];
struct Node{ int x,y; };
@heart4lor
heart4lor / G4GP_240_D&C.cpp
Last active February 4, 2017 00:42
[G4GP_240] Given 2 sorted arrays A and B of size N each. Print sum of middle elements of the array obtained after merging the given arrays. #tags: ACM, algorithm, D&C
#include <cstdio>
#include <algorithm>
using namespace std;
int median(int arr[], int n)
{
if (n%2 == 0)
return (arr[n/2] + arr[n/2-1])/2;
else
return arr[n/2];
@heart4lor
heart4lor / POJ_1166_DFS.cpp
Last active February 6, 2017 15:23
[POJ_1166] There are nine clocks in a 3*3 array (figure 1). The goal is to return all the dials to 12 o'clock with as few moves as possible. There are nine different allowed ways to turn the dials on the clocks. Each such way is called a move. Select for each move a number 1 to 9. That number will turn the dials 90' (degrees) clockwise on those …
#include <iostream>
#include <fstream>
#include <numeric>
using namespace std;
int t[10];
int b[10];
int s[10];
int path[1000];
int pnum;
@heart4lor
heart4lor / NYOJ_915_greedy.c
Last active February 4, 2017 00:43
[NYOJ_915] Shiva得到了两个只有加号和减号的字符串,字串长度相同。Shiva一次可以把一个加号和它相邻的减号交换。他想知道最少需要多少次操作才能把第一个字符串变换成第二个字符串。你现在要去帮助他完成那个这个问题。 #tags: ACM, algorithm, greedy
#include <stdio.h>
#include <string.h>
int main()
{
freopen("input.txt", "r", stdin);
char a[5000];
char b[5000];
while (~scanf("%s%s", a, b))
{
int m1 = 0, m2 = 0;