03 2020 档案
摘要:link Solution: follow1 / follow 2 means the established string follow along s1 / s2.At start, follow1=follow2=1.For instance, s1 = "leetcode", s2 = "l
阅读全文
摘要:link 题解可参考:https://www.luogu.com.cn/blog/cicos/solution-p2613# int a,b; const int mod=19260817; int x,y; int getint(){ char c=getchar(); int res=0; wh
阅读全文
摘要:link 题解可参考:https://www.luogu.com.cn/blog/cicos/solution-p1082# #include <bits/stdc++.h> # define LL long long using namespace std; LL a,b; LL x,y; voi
阅读全文
摘要:link int M,N; int arr[1001]; void dfs(vector<int>& post, int idx){ if(idx>N) return ; dfs(post,idx*2); dfs(post,idx*2+1); post.push_back(arr[idx]); }
阅读全文
摘要:link int N,M; int ind[1001]; int le[1001]; int main(){ cin>>N>>M; vector<vector<int>> adj(N+1); for(int i=0;i<M;i++){ int u,v; cin>>u>>v; ind[v]++; ad
阅读全文
摘要:link 搞不懂为什么找不到要+1,难道是为了区别找的到? int N; int Msize, M; bool isprime(int n){ if(n<=1) return false; for(int i=2;i*i<=n;i++){ if(n%i==0) return false; } ret
阅读全文
摘要:link 解法: 本题是bst,无需建树。按前序遍历的顺序检查u,v是否在当前点的左右即可。 int M,N; unordered_set<int> intree; int pre[10002]; int main(){ cin>>M>>N; for(int i=1;i<=N;i++){ cin>>
阅读全文
摘要:link int sum[220][220]; int mi[220][220]; int ma[220][220]; int p[220]; int main(){ int N; cin>>N; for(int i=1;i<=N;i++){ scanf("%d", p+i); p[i+N]=p[i
阅读全文
摘要:link 题解: 找n个互不相邻的披萨,求最大组合。若有两个相邻,a,b, 则吃a时b必须已经被吃掉,且是被自己吃掉;吃b时a必须已经被吃掉,且是被自己吃掉,矛盾,故互不相邻。 下面证明n个互不相邻的披萨可以顺利吃完。n=1满足条件。设n-1满足条件。n个披萨之间gap有n个,且这些gap被2n个披
阅读全文
摘要:link #include <iostream> #include <vector> #include <set> # define LL long long using namespace std; struct Node{ int key; int freq; Node(int k, int f
阅读全文
摘要:link 思路: 不可以bfs求最短路!因为到达中间点的最短路可能不唯一,无法取舍,而且中间点的选择会影响到后面点,必须全部考虑中间点的情况。 只能dfs了。 #include <iostream> #include <cstring> #include <vector> #include <uno
阅读全文
摘要:man 7 signal (默认处理动作) 杀死父进程: 由父进程杀死3号子进程: raise 函数,给本进程传递信号 abort 函数 setitimer 函数 (实现alarm) (第一次5s发SIGALRM,之后每隔3s发一次。signal()函数用于捕捉信号) 实现alarm 信号集处理函数
阅读全文
摘要:link class CustomStack { public: vector<int> stk, inc; int msize; CustomStack(int maxSize) { msize=maxSize; inc.resize(msize); } void push(int x) { if
阅读全文
摘要:link class Solution { public: #define LL long long int maxPerformance(int n, vector<int>& speed, vector<int>& efficiency, int k) { vector<pair<int,int
阅读全文
摘要:#include <iostream> #include <algorithm> # define LL long long using namespace std; const int maxn=11000002; char data[maxn<<1]; int len[maxn<<1]; int
阅读全文
摘要:link #include <iostream> # define LL long long using namespace std; LL b; LL p,k; int main(){ scanf("%lld%lld%lld", &b, &p, &k); LL d=p; LL ans=1; LL
阅读全文
摘要:link #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <set> #include <unordered_map> #include <
阅读全文
摘要:link #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <set> #include <unordered_map> #include <
阅读全文
摘要:link Dijkstra: #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstring> # define LL long long using namespace st
阅读全文
摘要:link #include <iostream> #include <cstring> #include <queue> #include <cmath> #include <unordered_map> #include <algorithm> #include <stack> # define
阅读全文
摘要:(read默认是阻塞的,会一直等着,直到读到,所以会打印) 实现 ps aux | grep bash #include <stdio.h> #include <unistd.h> int main() { int fd[2]; pipe(fd); pid_t pid = fork(); if(pi
阅读全文
摘要:link class Skiplist { public: struct Node{ int key; Node* down; Node* next; Node(int k, Node* d, Node *n){ key=k; down=d; next=n; } }; Node* head; Ski
阅读全文
摘要:link class LRUCache { public: int cap; int size; unordered_map<int,int> ktov; // key to value unordered_map<int,list<int>::iterator> ktoi; // key to i
阅读全文
摘要:link class LFUCache { public: unordered_map<int,int> ktov; // key to value unordered_map<int,int> ktof; //key to freq unordered_map<int,list<int>> fto
阅读全文
摘要:link #include <cstdio> #include <cmath> #include <vector> #include <algorithm> #include <climits> #include <unordered_map> #include <cstdio> #include
阅读全文
摘要:link #include <cstdio> #include <cmath> #include <vector> #include <algorithm> #include <climits> #include <unordered_map> #include <cstdio> #include
阅读全文
摘要:link #include <bits/stdc++.h> # define LL long long using namespace std; class TreeNode{ public: int val; TreeNode* left; TreeNode* right; TreeNode(in
阅读全文
摘要:link select t3.id as transactions_count, if(t5.cnt is null,0,t5.vcnt) as visits_count from ( select t0.id from ( select @num:=@num+1 as id from (selec
阅读全文
摘要:PCB 进程控制块 getenv 获取环境变量 父进程先死,子进程变为孤儿。 加sleep,让父进程最后死。 查看进程信息: ps aux 有ppid信息: ps ajx 杀死进程: kill -9 pid kill表示给进程发信号,-9表示发9号信号 kill -l 查看信号信息 生5个子进程 精
阅读全文
摘要:link /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ /** *
阅读全文
摘要:link Solution 1 : min cost flow Break each cell into two nodes i and i', connect i to i' (i+mn) with an edge with flow 1, cost 0. For each cell i, con
阅读全文

浙公网安备 33010602011771号