Skip to content

Instantly share code, notes, and snippets.

View istepura's full-sized avatar

Igor Stepura istepura

  • Kanata, Ontario
View GitHub Profile
@istepura
istepura / agnoster_molested.theme
Last active July 31, 2019 19:56
Heavily molested Agnoster ZSH theme. https://imgur.com/prbnedZ
# vim:ft=zsh ts=2 sw=2 sts=2
autoload -U colors && colors
typeset -aHg AGNOSTER_PROMPT_SEGMENTS=(
prompt_status
prompt_context
prompt_virtualenv
prompt_dir
prompt_git
)
@istepura
istepura / fibonacci.cpp
Last active August 29, 2015 14:04
O(n) and O(log(n)) calculation of Fibonacci numbers
#include <cstdint>
#include <cassert>
#include <cstdio>
#include <cstring>
/*
* Regular O(n) calculation of n-th Fibonacci number
*/
uint_fast64_t fib_linear(uint_fast64_t n)
{
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[1001];
int n, m, sum, minsum, dff;
inline int abs(int a){
@istepura
istepura / bit.cpp
Created July 22, 2014 08:25
Simple Fenwick (binary indexed tree) tree implementation
#define MAXSZ 200001
int sum[MAXSZ];
inline void init(int sz){
fill_n(sum, sz + 1, 0);
}
inline void update(int* arr, int sz, int idx, int val)
{
while(idx <= sz){
@istepura
istepura / uf.cpp
Created July 22, 2014 03:45
Union-Find with path compression
#include <algorithm>
using namespace std;
/*
* See http://algs4.cs.princeton.edu/15uf/ for details
*/
#define MAXSZ 3000
int parent[MAXSZ];
int rnk[MAXSZ];
int len[MAXSZ];
@istepura
istepura / .vimrc
Last active February 25, 2021 17:54
vim config file
set nocompatible
set encoding=utf-8
set cinoptions+=n2
set cinkeys+=0=break
set shiftwidth=4
set expandtab
set tabstop=4
set laststatus=2
set nocompatible
set nobackup
@istepura
istepura / 1062.cxx
Created April 24, 2014 05:29
UVA 1062 "Containers"
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <iterator>
#include <cstdint>
#include <bitset>
@istepura
istepura / 893.tst
Created April 10, 2014 10:14
UVA problem 893 test data and test output (correct output). http://uva.onlinejudge.org/external/8/893.html
This file has been truncated, but you can view the full file.
872845 19 6 2842
786073 4 11 2902
776914 28 3 2151
681059 13 4 2468
437565 28 4 2600
943726 26 8 2670
567670 5 12 2357
658280 13 9 2453
625068 23 2 2734
672546 23 6 2543
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <algorithm>
#include <locale>
using namespace std;
inline string srt(const string& s){
@istepura
istepura / 10919.cpp
Created March 25, 2014 00:45
UVA 10919 - Prerequisites?
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cctype>
using namespace std;
char taken[10001] = {0};
char line[1024] = {0};