This file contains hidden or 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
class UnionFind{ | |
public: | |
int *par; | |
int *rank; | |
UnionFind(int n) { | |
par = new int[n]; rank = new int[n]; | |
for (int i = 0; i < n; ++i){ par[i] = i; rank[i] = 0;} | |
} | |
~UnionFind() { delete par; delete rank; } |
This file contains hidden or 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
import urllib2 | |
import lxml.html | |
html = urllib2.urlopen('ここにWebページのurl').read() | |
d = lxml.html.fromstring(html) | |
links = d.xpath('//a') | |
for link in links: | |
print link.attrib.get('href') |
This file contains hidden or 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 <iostream> | |
#include <map> | |
#include <string> | |
#include <vector> | |
#include <cstdio> | |
#include <math.h> | |
#include <algorithm> | |
#include <queue> | |
#include <tuple> | |
#include <stack> |
This file contains hidden or 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
import collections | |
def solve(A, B, C, D): | |
count = 0 | |
AB = create_pairs(A, B) | |
CD = create_pairs(C, D) | |
for k, v in AB.items(): | |
count += CD[-k] * v | |
return count |
This file contains hidden or 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
%{ | |
enum { | |
INT = 1, | |
FLOAT, | |
ID, | |
NUM, | |
REAL, | |
COMMA, | |
EQ, | |
EX, |
This file contains hidden or 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
int 3 | |
int 6 | |
mov [207], a | |
mov [206], b | |
jgt 8, [207], 0 | |
inc [236] | |
jlt 9, [236], 3 | |
mov [207], 0 | |
mov [236], 0 | |
int 3 |
This file contains hidden or 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 <stdio.h> | |
#define N 5 | |
int main(int argc, char const *argv[]) | |
{ | |
int hoge[N][N]; | |
for (int i = 0; i < N; ++i){ | |
for (int j = 0; j < N; ++j){ | |
hoge[i][j] = i * 10 + j; | |
} |
This file contains hidden or 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 <stdio.h> | |
int main(int argc, char const *argv[]) | |
{ | |
int hoge[5]; | |
for (int i = 0; i < 5; ++i){ | |
hoge[i] = i * 10; | |
} | |
printf("%d\n", hoge[1]); | |
printf("%d\n", 1[hoge]); |
This file contains hidden or 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 <stdlib.h> | |
#include <stdio.h> | |
int main(int argc, char const *argv[]) | |
{ | |
int N = 100; | |
int* hoge = (int *)malloc(sizeof(int)* N); | |
for (int i = 0; i < N; ++i) | |
{ | |
hoge[i] = i; |
This file contains hidden or 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
class SplitStoneGame: | |
def winOrLose(self, number): | |
number = sorted(list(number)) | |
i = 0 | |
while len(number) > 2: | |
if number[-1] == 1: | |
break | |
selected = number.pop(-1) | |
A = selected / 2 | |
B = selected - A |