Skip to content

Instantly share code, notes, and snippets.

View morris821028's full-sized avatar
💭
I may be slow to respond.

Morris Yang, Shiang-Yun Yang morris821028

💭
I may be slow to respond.
View GitHub Profile
/*
给出一个tree, 每一个node都有一个value, 问tree里面相同value的node连接成最长路径的大小(edge的数量).
tree是要自己建的, 输入是两个array, 第一个array表示每个node的value, 第二个array表示所有的边
例如[1,1,1], [1,2,1,3] -> 2, 说明这个tree有3个node, value都是1, 然后node1和node2有边, node1和node3也有边, 最长的路径是2 -> 1 -> 3或者反过来, 总共两条边, 输出2
*/
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <algorithm>
@morris821028
morris821028 / setup.sh
Created February 8, 2018 07:32
View GUI Application: Docker for Windows
apt-get update
apt-get install openssh-server
mkdir /var/run/sshd
chmod 0755 /var/run/sshd
/usr/sbin/sshd
useradd --create-home --shell /bin/bash --groups sudo username ## includes 'sudo'
passwd username ## Enter a password
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 30005;
struct Edge {
int to, d, l;
Edge(int to=0, int d=0, int l=0):
to(to), d(d), l(l) {}
};
vector<Edge> g[MAXN];
int64_t ret = 0;
@morris821028
morris821028 / How-to-install.md
Last active February 26, 2018 23:33
AspectJ Example
#include <stdio.h>
#include <vector>
using namespace std;
vector<int> A;
int func() {
A.push_back(3);
A.push_back(4);
return 5;
}
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
public class Main {
static class MEdge {
int x, y;
package bsh;
import org.junit.Test;
public class MemoryTest {
static public double printUsage() {
double cap = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
cap /= 1048576;
System.out.printf("Usage %f MB\n", cap);
@morris821028
morris821028 / Main.java
Created July 16, 2018 12:23
Java Iterator Performance - HashSet/TreeSet
import java.util.*;
public class Main {
static class Point implements Comparable<Point> {
long x;
long y;
public Point(long x, long y) {
this.x = x;
@morris821028
morris821028 / xxx.vmx
Created August 19, 2019 13:23
MapleStory VMware v218
SMBIOS.reflectHost = "TRUE"
hypervisor.cpuid.v0 = "FALSE"
@morris821028
morris821028 / Persistent.java
Last active December 15, 2019 13:21
Purely functional queues in Java
package persistent;
import java.util.Scanner;
public class Persistent {
public static interface PStack<T> {
public boolean isEmpty();
public long size();