Skip to content

Instantly share code, notes, and snippets.

@msg555
msg555 / 3dhull.cpp
Last active April 1, 2023 17:39
3D Convex Hull
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cassert>
using namespace std;
@msg555
msg555 / mobiles.cpp
Created February 23, 2013 01:50
Mobiles from IOI 2001
#include <iostream>
using namespace std;
/* MAXN needs to be a power of 2. */
#define MAXN (1 << 10)
/* A should be initialized to zeroes. */
int A[MAXN][MAXN];
@msg555
msg555 / range2D.cpp
Created February 23, 2013 02:01
2D Range Tree Query Example
/*
LANG: C++
*/
#include <iostream>
#include <cstdio>
using namespace std;
#define MAXN 512
@msg555
msg555 / gather.cpp
Created February 23, 2013 02:49
Solution To 'The Gathering'
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <stack>
#include <queue>
@msg555
msg555 / suffix.cpp
Created March 21, 2013 04:36
Suffix Array Implementation
struct suffix_array {
suffix_array(const char* S) : N(strlen(S)) {
vector<int> V;
for(int i = 0; i < N; i++) V.push_back(S[i]);
init(V);
}
suffix_array(const vector<int>& VV) : N(VV.size()) {
vector<int> V(VV);
init(V);
@msg555
msg555 / gist:5418199
Last active October 30, 2021 19:27
Stack Switching
#include <stdio.h>
#include <stdlib.h>
#define STACK_SIZE (1 << 26)
#define STACK_PAD 128
int rec(int n) {
return n == 0 ? 0 : rec(n - 1) + 1;
}
@msg555
msg555 / wombats.cpp
Created July 18, 2013 00:57
Problem "Wombats" From IOI 2013 Day 1
#include "wombats.h"
#include <algorithm>
#include <cstring>
using namespace std;
#define K 15
#define INF 5000010
@msg555
msg555 / game.cpp
Last active April 9, 2020 17:35
Problem "Game" From IOI 2013 Day 2
#include "game.h"
#define MAXR 1000000000
#define MAXC 1000000000
#include <assert.h>
#include <stddef.h>
long long gcd2(long long X, long long Y) {
if(X == 0 || Y == 0) {
@msg555
msg555 / suffix_linear.cpp
Created September 14, 2013 20:58
Linear time DC3 Suffix Array Construction (And driver program to solve http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2507)
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
#define MAXN 1010
int AN;
#include <iostream>
#include <vector>
using namespace std;
string S;
int result;
void solve(int x, int L, int N, int ones) {
if (result > 1) return;