Skip to content

Instantly share code, notes, and snippets.

View shiponcs's full-sized avatar
💻
Coding

Abdul Matin shiponcs

💻
Coding
View GitHub Profile
@shiponcs
shiponcs / UVA-459.cpp
Last active June 8, 2020 03:47
topic: DSU
#include <iostream>
using namespace std;
int link[5009], size[5009];
void init(int c)
{
for(int i = 0; i < c; i++) link[i] = i, size[i] = 1;
}
int root(int x)
{
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;
#define pdd pair <double, double>
struct edge{
@shiponcs
shiponcs / Uva-p10130(2Darray).cpp
Last active November 3, 2019 15:35
DP- Knapsack
#include <iostream>
#include <string.h>
using namespace std;
int p[10009], w[10009];
int main()
{
int tc;
cin >> tc;
@shiponcs
shiponcs / 1225-I.cpp
Last active May 14, 2020 10:14
Timus DP 1225-Flag
#include <iostream>
using namespace std;
using ull = unsigned long long;
int main()
{
int n;
cin >> n;
ull dp[n + 1][2]; // dp[i][0] i-th stripe ends with white
dp[1][0] = dp[1][1] = dp[2][0] = dp[2][1] = 1;
@shiponcs
shiponcs / 1119.cpp
Created November 3, 2019 15:03
Timus-DP
#include <iostream>
#include <map>
#include <unordered_map>
#include <utility>
#include <vector>
#include <limits.h>
#include <float.h>
#include <math.h>
using namespace std;
int r, c;
@shiponcs
shiponcs / rodcutting1Darray.cpp
Last active November 3, 2019 16:55
DP-rodcutting
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int size;
cin >> size;
int profit[size];
for(int i = 0; i < size; i++) cin >> profit[i];
@shiponcs
shiponcs / 1106.cpp
Created November 5, 2019 05:47
Timus- 1106. Two Teams
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, t, tt;
cin >> n;
vector< int > friends[n + 1];
for(int i = 1; i <= n; i++){
@shiponcs
shiponcs / CF-20C.cpp
Created November 20, 2019 15:00
Dijastra Algorithm
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
long long const inf = 1e13;
vector< int > g[100009];
vector< int > cost[100009];
@shiponcs
shiponcs / UVa-p558.cpp
Last active November 27, 2019 17:41
Bellman ford algorithm(negative cycle finding)
#include <iostream>
#include <vector>
using namespace std;
const int inf = 1e8;
int main()
{
int tcc;
@shiponcs
shiponcs / kruskal.cpp
Last active November 27, 2019 15:43
MST with Kruskal
//author: Abdul Matin
void init(int nodes)
{
for(int i = 1; i <= nodes; i++) link[i] = i, size[i] = 1;
}
int root(int x)
{
if(x != link[x]) return (link[x] = root(link[x]));