Skip to content

Instantly share code, notes, and snippets.

View irfanabduhu's full-sized avatar

Irfanul Hoque irfanabduhu

View GitHub Profile
@irfanabduhu
irfanabduhu / abc143e.cpp
Last active October 24, 2019 14:08
Graph
#include <iostream>
#include <climits>
using namespace std;
#define INF (ULLONG_MAX/3)
using ull = unsigned long long;
constexpr int MAXN = 3e2;
ull path[MAXN][MAXN];
ull tour[MAXN][MAXN];
@irfanabduhu
irfanabduhu / coin.cpp
Last active October 26, 2019 12:14
Notebook
// Given a set of coin values coins = {c1, c2, ..., ck}
// and a target sum of money n,
// form the sum n using as few coins as possible.
// You can use any coin as many times as you want.
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#define INF (INT_MAX / 2)
@irfanabduhu
irfanabduhu / 1119.cpp
Last active October 29, 2019 18:35
Timus: DP
#include <iostream>
#include <cmath>
using namespace std;
constexpr int MAXN = 1e3 + 1;
double grid[MAXN][MAXN];
int main(void)
{
int n, m, k;
@irfanabduhu
irfanabduhu / srm764a.cpp
Last active October 28, 2019 08:17
Disjoint Set-Union
// Source: https://community.topcoder.com/stat?c=problem_statement&pm=15686
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define maxn (55 * 55)
static int parent[maxn];
@irfanabduhu
irfanabduhu / 1106.cpp
Created October 31, 2019 12:23
Timus: Graph
// ACM Timus 1106: Two Teams
// Source: http://acm.timus.ru/problem.aspx?space=1&num=1106
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
constexpr int MAXN = 1e2;
vector<int> adj[MAXN];
bool visited[MAXN];
@irfanabduhu
irfanabduhu / 1494.cpp
Created November 1, 2019 13:04
Timus: Data Structure
// Source: http://acm.timus.ru/problem.aspx?space=1&num=1494
#include <iostream>
#include <stack>
using namespace std;
int main(void)
{
int n;
cin >> n;
bool cheating = false;
@irfanabduhu
irfanabduhu / 101.cpp
Last active November 6, 2019 07:59
LeetCode: Graph
// Source: https://leetcode.com/problems/symmetric-tree/
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
@irfanabduhu
irfanabduhu / aba12c.cpp
Last active November 7, 2019 05:25
SPOJ
// DP
// Source: https://www.spoj.com/status/ABA12C
#include <iostream>
#include <climits>
#include <vector>
#define INF (INT_MAX / 2)
using namespace std;
int main(void)
{
@irfanabduhu
irfanabduhu / 476b.cpp
Created February 6, 2020 05:42
Codeforces
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(void)
{
string s1, s2;
cin >> s1 >> s2;
#include <iostream>
#include <vector>
using namespace std;
void helper(int n, int i, vector<bool> res);
void binary(int n) {
vector<bool> res(n);
helper(n, 0, res);
}