Skip to content

Instantly share code, notes, and snippets.

View nathanPro's full-sized avatar

Nathan Proença nathanPro

  • None
  • São Paulo
View GitHub Profile
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
// Define generic interface for types
struct type_def {
void (*print)(void *);
int (*cmp)(void *, void *);
};
#include <algorithm>
#include <complex>
#include <iostream>
#include <iterator>
#include <tuple>
#include <vector>
namespace geo {
template <typename T> using point = std::complex<T>;
#include "bits/stdc++.h"
using namespace std;
int fn(int a, ...) {
return 1;
}
double fn(int a, int b) {
return 1.0;
}
#include "bits/stdc++.h"
template<typename T>
std::vector<T> dibs(size_t n){
std::vector<T> ans;
ans.reserve(n);
return ans;
}
template<typename Monoid>
#include "bits/stdc++.h"
#define all(v) begin(v), end(v)
using namespace std;
using ll = int64_t;
const int N = 1e5 + 7;
int n;
int c[N];
vector<int> G[N];
@nathanPro
nathanPro / knapsack.cpp
Last active July 26, 2016 04:47
Knapsack se aproveitando de C++11
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int N = (2e3) + 7;
int n, k, w[N], v[N];
int _S[N][N];
int& S(int i, int w) { return (w >= 0) ? _S[i][w] : _S[N-1][N-1]; }
int s(int i, int w) { return max({S(i+1,w), v[i] + S(i+1,w-::w[i])}); }
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
template<typename T> inline void _max(T& a, T b){ a = max(a,b); }
template<typename T> inline void _min(T& a, T b){ a = min(a,b); }
const int N = 1e6+7;
int x[N], f[N], y[N], T[N][2];
int s[2], ts;
void split(int t, int k){
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
template<typename T> inline void _max(T& a, T b){ a = max(a,b); }
template<typename T> inline void _min(T& a, T b){ a = min(a,b); }
int main(){
}
@nathanPro
nathanPro / counting.rb
Created August 8, 2015 15:43
PD com combinações em ruby
$comb = Hash.new do |comb, n|
if n == 0
comb[n] = Hash.new(0)
comb[0][0] = 1;
else
comb[n] = Hash.new do |hash, k|
if k == 0
hash[k] = 1;
else
hash[k] = comb[n-1][k-1] + comb[n-1][k];
#include<bits/stdc++.h>
using namespace std;
typedef int num;
typedef int cood;
typedef int point;
const int MP = 1002;
const double PI = (acos(-1.0));
const double eps = (1e-9);
cood x[MP], y[MP];
point anchor, in[MP], hull[MP];