Skip to content

Instantly share code, notes, and snippets.

View mryoshio's full-sized avatar

YOSHIOKA A mryoshio

View GitHub Profile
@mryoshio
mryoshio / constructor_destructor.cpp
Created December 11, 2013 16:29
play with constructor / destructor in C++
#include <iostream>
#include <vector>
using namespace std;
struct X
{
int val;
void out(const string& s, int nv) {
@mryoshio
mryoshio / dfs.cpp
Created December 15, 2013 05:59
sonomamma dfs
#include <iostream>
#define MAX_N 20
using namespace std;
int a[MAX_N];
int n, k;
bool dfs(int i, int sum) {
@mryoshio
mryoshio / lake_count.cpp
Created December 15, 2013 06:44
lake count
#include <iostream>
#include <fstream>
#define N 10
#define M 12
using namespace std;
char lake[10][12];
@mryoshio
mryoshio / enum_test.cpp
Created December 23, 2013 14:41
enum in C++
using namespace std;
enum Color {
red, green, blue,
white = 10, black = white,
silver, gold = 99
};
int main()
{
@mryoshio
mryoshio / lcs_naive.cpp
Created February 24, 2014 16:33
Naive implementation of LCS
#include <iostream>
#include <string>
using namespace std;
int N, M;
string S, T;
int calc(int n, int m) {
if (n == N || m == M)
@mryoshio
mryoshio / lcs_memo.cpp
Created February 24, 2014 16:35
Implementation of LCS with memo
#include <iostream>
#include <string>
#include "../d.h"
using namespace std;
int N, M;
string S, T;
int dp[1001][1001];
@mryoshio
mryoshio / lcs_dp.cpp
Created February 24, 2014 16:36
DP of LCS
#include <iostream>
#include <string>
#include "../d.h"
using namespace std;
int N, M;
string S, T;
int dp[1001][1001];
@mryoshio
mryoshio / compress_decompress.rb
Created March 1, 2014 13:53
compress, decompress
def decompress(args)
ans = []
args.each do |a|
if a.is_a? Array
ans.push a.last*a.first
else
ans.push a
end
end
ans.join("")
@mryoshio
mryoshio / sum.cpp
Created March 9, 2014 05:41
sum.cpp
template<typename Container, typename Value>
Value sum(const Container& c, Value v)
{
for (auto x : c)
v += x;
return v;
}
#include <iostream>
#include <string>
using namespace std;
class person {
private:
int age;
string name;
public: