Skip to content

Instantly share code, notes, and snippets.

View osjayaprakash's full-sized avatar
💭
I may be slow to respond.

Jayaprakash Sundararaj osjayaprakash

💭
I may be slow to respond.
View GitHub Profile
#include <iostream>
#include <cstring>
using namespace std;
int buildlps (char * pat, int m, int *lps){
lps[0] = lps[1] = 0;
for(int i=2; i<=m; i++){
int j = lps[i-1];
while(1){
@osjayaprakash
osjayaprakash / lego.cpp
Created August 31, 2013 18:15
lego blocks, cpp, hackerrank
#include <iostream>
using namespace std;
#define MOD 1000000007
typedef unsigned long long ull;
ull dp[1001]; // with rep
@osjayaprakash
osjayaprakash / SPOJ-IKEYB.cpp
Created January 16, 2013 17:29
SPOJ, IKEYB, I KEYBOARD
#include <iostream>
#include <cstdio>
typedef unsigned long long ull;
typedef unsigned u;
using namespace std;
const u INF=1<<31;
u f[105];
char letter[105];
@osjayaprakash
osjayaprakash / SPOJ-TRECOUNT.cpp
Created January 16, 2013 06:30
SPOJ, TRECOUNT, DP
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
const ull MOD = 1000000000ULL;
const int MH=15;
ull dp[MH+2][4096];
@osjayaprakash
osjayaprakash / SPOJ-WEIGHT.cpp
Created December 31, 2012 20:38
SPOJ,WEIGHT
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
namespace IO{
const int SIZE = 1 << 19;
char buff[SIZE], *p = buff + SIZE;
char read_char(){
if( p == buff + SIZE ){
fread( buff, 1, SIZE, stdin );
@osjayaprakash
osjayaprakash / SPOJ-DCEPC501.cpp
Last active December 10, 2015 10:38
DCEPC501
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define MAX 100012
namespace IO{
const int SIZE = 1 << 19;
char buff[SIZE], *p = buff + SIZE;
@osjayaprakash
osjayaprakash / SPOJ-GOV01.cpp
Created December 31, 2012 18:08
SPOJ, Matrix Exponentiation, Fibonacci, Recurrence Equation
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
ull mod = 1000000007;
class _matrix{
public:
ull x[2][2];
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int v[205][205],N,M;
int dp[2][205][205];
int init(){
@osjayaprakash
osjayaprakash / SPOJ-template.cpp
Last active December 10, 2015 09:08
SPOJ, TEMPLATE, CPP
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <vector>
namespace IO{
const int SIZE = 1 << 19;
char buff[SIZE], *p = buff + SIZE;
char read_char(){
@osjayaprakash
osjayaprakash / SPOJ-BYTESE2.cpp
Created December 29, 2012 17:36
BYTESE2, SPOJ
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define PB push_back
typedef pair <int, bool> pii;
typedef unsigned long long ull;