This file contains hidden or 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
/* wikioi 1154, 能量项链, http://www.wikioi.com/problem/1154 */ | |
#include <stdio.h> | |
#include <memory.h> | |
#include <limits.h> | |
#define MAXN 101 | |
int N; /** 矩阵的个数. */ | |
int a[MAXN]; | |
int p[MAXN]; /** 矩阵Ai的维度是p[i-1]xp[i]. */ |
This file contains hidden or 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
/** | |
* @file string_serialization.c | |
* compile, gcc -std=c99 string_serialization.c ... | |
* | |
* @author Frank Dai | |
* @email soulmachine@gmail | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> /* for strtoll, ato */ | |
#include <string.h> |
This file contains hidden or 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
/* POJ 3630 Phone List, http://poj.org/problem?id=3630 */ | |
#define MAXN 10000 /** 输入的编码的最大个数. */ | |
#define CHAR_COUNT 10 /** 字符的种类,也即单个节点的子树的最大个数 */ | |
#define MAX_CODE_LEN 10 /** 编码的最大长度. */ | |
#define MAX_NODE_COUNT (CHAR_COUNT * MAXN + 1) /** 字典树的最大节点个数. */ | |
/* 等价于复制粘贴,这里为了节约篇幅,使用include,在OJ上提交时请用复制粘贴 */ | |
#include "trie_tree.c" /* 见“树->Trie树”这节 */ |
This file contains hidden or 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
// wikioi 1079 回家, http://www.wikioi.com/problem/1079/ | |
#include <iostream> | |
#include <queue> | |
#include <map> | |
#include <utility> | |
#include <climits> | |
using namespace std; | |
/** 边的权值类型,可以为int, float, double. */ |
This file contains hidden or 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
/* POJ 3620 Avoid The Lakes, http://poj.org/problem?id=3620 */ | |
#include <stdio.h> | |
#include <string.h> | |
/* N, M最大值是100,加一圈0可以防止越界 */ | |
#define MAX 102 | |
int N, M, K; | |
int map[MAX][MAX]; |
This file contains hidden or 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
// LeetCode, 4Sum | |
// 先排序,然后二分查找 | |
class Solution { | |
public: | |
vector<vector<int>> fourSum(vector<int>& num, int target) { | |
vector<vector<int>> result; | |
if (num.size() < 4) return result; | |
sort(num.begin(), num.end()); | |
auto last = num.end(); |
This file contains hidden or 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 <string> | |
#include <stack> | |
#include <vector> | |
using namespace std; | |
bool is_operator(const char op) { | |
return string("+-*/").find(op) != string::npos; |
This file contains hidden or 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 <string> | |
#include <utility> | |
#include <vector> | |
#include <climits> | |
#include <cstdio> | |
using namespace std; | |
bool detect(vector<string> square) { |
This file contains hidden or 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 <cstdio> | |
#include <sstream> | |
#include <vector> | |
#include <queue> | |
#include <stack> | |
#include <map> | |
#include <set> | |
#include <unordered_set> | |
#include <unordered_map> |
This file contains hidden or 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
// LeetCode, 4Sum | |
// 用一个 hashmap 先缓存两个数的和 | |
// 时间复杂度O(n^2),空间复杂度O(n^2) | |
// @author 龚陆安(http://weibo.com/luangong) | |
class Solution { | |
public: | |
vector<vector<int>> fourSum(vector<int>& num, int target) { | |
vector<vector<int>> result; | |
if (num.size() < 4) return result; | |
sort(num.begin(), num.end()); |