This file contains 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
struct array_deleter | |
{ | |
void operator ()(char * p) | |
{ | |
delete[] p; | |
} | |
}; | |
class A{ | |
public: |
This file contains 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* argv[]) { | |
int* vals; | |
size_t n; | |
size_t m; | |
int i; |
This file contains 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
MOD=1000000007 | |
def solve a, b | |
#puts "solve #{a} #{b}" | |
return 1 if a == 0 or b == 0 | |
$cache = (a + 1).times.map{[-1] * (b + 1)} unless $cache | |
return $cache[a][b] if $cache[a][b] != -1 | |
r = solve(a, b - 1) | |
r += solve(a - 1, b) if a - 1 > b | |
$cache[a][b] = r |
This file contains 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 <vector> | |
#include <unordered_map> | |
using namespace std; | |
struct Tree { | |
int value; | |
Tree(int v) : value(v) {} | |
vector<Tree*> c; | |
}; |
This file contains 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 <set> | |
using namespace std; | |
int common_prefix(const string& a, const string& b) { | |
int i = 0; | |
while (i < a.size() && i < b.size() && a[i] == b[i]) | |
++i; | |
return i; |
This file contains 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 <vector> | |
#include <algorithm> | |
#include <math.h> | |
using namespace std; | |
void gen_primes(vector<int>& primes, int max) { | |
primes.resize(max + 1); | |
for (int i = 2; i < primes.size(); ++i) | |
if (primes[i] == 0) |
This file contains 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
gets.to_i.times do |i| | |
m = [] | |
c = gets.chomp | |
if c == "0" | |
puts "Case #{i+1}: 0 0" | |
else | |
c.size.times do |i1| | |
c.size.times do |i2| | |
c[i1],c[i2] = c[i2],c[i1] | |
m << c.clone |
This file contains 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
DIR={'<'=>[-1, 0], '^'=>[0, -1], '>'=>[1, 0], 'v'=>[0, 1]} | |
def rotate maze | |
maze.each_with_index do |row, y| | |
row.size.times do |x| | |
c = row[x] | |
ind = DIR.keys.index c | |
row[x] = DIR.keys[(ind + 1) % 4] if ind | |
end | |
end |