This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <iomanip> | |
#include <iostream> | |
using namespace std; | |
int main(void) | |
{ | |
string s1, s2; | |
cin >> s1 >> s2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) {} | |
* }; | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
constexpr int MAXN = 1e3 + 1; | |
double grid[MAXN][MAXN]; | |
int main(void) | |
{ | |
int n, m, k; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]; |