随笔分类 - Algorithm
classic algorithm, problem
摘要:说要写成对数时间复杂度,算了想不出来,写个O(n)的水了class Solution {public: int findPeakElement(const vector &num) { int len = num.size(); if (len last) { ...
阅读全文
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *...
阅读全文
摘要:#include #include using namespace std;long long gcd(long long a, long long b) { long long r; while (r = (a % b)) { a = b; b = r; ...
阅读全文
摘要:#include #include #include #include #include using namespace std;int main() { int N, M; scanf("%d%d", &N, &M); vector nums(N); vector ...
阅读全文
摘要:#include #include #include #include using namespace std;bool mycmp(const string& a, const string& b) { string ta = a + b; string tb = b + a; ...
阅读全文
摘要:有一个两分的case出现段错误,真是没救了,估计是要写bfs的形式,可能栈溢出了#include #include #include #include #include #include using namespace std;int G[1001][1001] = {0};class Man {p...
阅读全文
摘要:#include #include #include #include using namespace std;int main() { int N,p; scanf("%d%d", &N, &p); if (N seq(N); for (int i=0; i m ...
阅读全文
摘要:题是别人出的,不按她的想法来也没办法,真心想k一顿#include #include using namespace std;const char* days[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};inline bool is_...
阅读全文
摘要:#include #include #include #include using namespace std;int main() { int N; double mcap, dist, davg; scanf("%lf%lf%lf%d", &mcap, &dist, &dav...
阅读全文
摘要:#include #include #include #include #include using namespace std;const char* d2cn[] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"...
阅读全文
摘要:#include #include #include using namespace std;int swap(vector &numpos, int va, int vb) { //printf("swap(%d at %d, %d at %d)\n", va, numpos[va], vb...
阅读全文
摘要:#include #include #include using namespace std;class MinStack2 {private: vector > mins; vector stack;public: void push(int x) { stack....
阅读全文
摘要:#include #include #include using namespace std;// 4 5 1 2// 1 2class Solution {public: int findMin(vector &num) { int len = num.size(); ...
阅读全文
摘要:又是考输入输出#include #include #include #include #include #include using namespace std;char buf[1048577];bool is_alphanumerical(char &ch) { if (ch >= '0'...
阅读全文
摘要:完全考输入输出#include #include #include #include #include #include #include using namespace std;unordered_map > idx_title;unordered_map > idx_author;unorder...
阅读全文
摘要:昨天做了一题通过率比这个高的居然没有全对,可是这题得多水相比之下#include #include #include using namespace std;const int NUM_RANGE = 10001;int tbl[NUM_RANGE];int main() { int N; ...
阅读全文
摘要:two sum题目,算是贪婪吧#include #include #include #include using namespace std;int main() { int N, M; scanf("%d%d", &N, &M); vector coins(N); ...
阅读全文
摘要:#include #include #include #include using namespace std;class Stu {public: char id[8]; char name[10]; char grade;};bool cmp_id(const Stu* a, ...
阅读全文
摘要:标准10背包#include #include #include #include using namespace std;const int ROWS = 10002;const int COLS = 102;char dp[ROWS][COLS];bool dfs(vector &coins, ...
阅读全文
摘要:#include #include #include using namespace std;int min_dist(vector &dsum, int a, int b) { if (a == b) return 0; if (a > b) { int t = a; ...
阅读全文

浙公网安备 33010602011771号