Skip to content

Instantly share code, notes, and snippets.

View krofna's full-sized avatar
💭
👨‍🎓

Mislav Blažević krofna

💭
👨‍🎓
View GitHub Profile
void init(string& P, vi& b)
{
int i = 0, j = -1; b[0] = -1;
while (i < P.size())
{
while (j >= 0 && P[i] != P[j]) j = b[j];
b[++i] = ++j;
}
}
#include <bits/stdc++.h>
#define _ << ' ' <<
using namespace std;
using ll = long long;
const int mod = 1e9 + 9;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >= 0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int pwr(int a, int p) {
;;; init.el --- my init
;;; Commentary:
;;; Code:
(require 'cc-mode)
(require 'time)
(setq user-full-name "Mislav Blažević"
user-mail-address "[email protected]"
c-default-style "bsd"
inhibit-splash-screen t
@krofna
krofna / insane.cpp
Created November 11, 2017 14:11
insane.cpp
int bt(int pos, int cur, int used)
{
if (pos == n)
return used == 7 ? 0 : 150000 * 5;
if (cur != -1 && D[pos][used][cur] != 0)
return D[pos][used][cur];
int bs = 5 * 150000;
for (int i = 0; i < 3; ++i)
if (!(used & 1 << i) || i == cur)
#include <iostream>
#include <vector>
#include <array>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<array<array<int, 2>, 2> > vaa;
@krofna
krofna / uva.el
Last active February 22, 2019 17:17
;;; uva.el --- interface to UVa online judge
;;; Commentary:
;;; Code:
(require 'json)
(require 'cc-mode)
(require 'cl)
(defconst uva-dir "~/Hacking/uva/")
(defconst uva-pdf-dir "~/Hacking/uva/pdf/")
(defconst uva-id "831136")
@krofna
krofna / kocka.cpp
Last active October 27, 2016 10:32
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
using namespace std;
int main()
{
int dubina, sirina;
cin >> dubina >> sirina;
@krofna
krofna / crane.cpp
Last active October 20, 2016 15:20
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;
typedef list<int>::iterator LI;
int find_derp(LI beg, int k, LI& out)
{
int ctr = 0;
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;
vector<int> K[3];
string s[3];
int max_size;
#include <iostream>
#include <vector>
using namespace std;
int T, B, W;
int gcd(int a, int b)
{
return ((b == 0) ? a : gcd(b, a % b));
}