随笔分类 -  PAT

摘要:link 解法: 模拟双端队列。刚开始的N*M个客户一次排队到窗口,并计算一下他们完成服务的时间点。对于每一个后面的人,看哪儿一个窗口最早有人出队,则排在次队,根据队尾的人计算一下此人的结束时间。 最后判断如果一个人的开始服务时间>=17:00,则sorry。 #include <bits/stdc 阅读全文
posted @ 2020-05-20 09:31 feibilun 阅读(233) 评论(0) 推荐(0)
摘要:link #include <iostream> #include <string> #include <vector> #include <algorithm> #include <climits> #include <cmath> using namespace std; int N, K, M 阅读全文
posted @ 2020-05-11 18:19 feibilun 阅读(140) 评论(0) 推荐(0)
摘要:link int getint(){ int res=0; char c=getchar(); while(!(c>='0' && c<='9')) c=getchar(); while(c>='0' && c<='9'){ res=res*10+(c-'0'); c=getchar(); } re 阅读全文
posted @ 2020-05-09 08:23 feibilun 阅读(121) 评论(0) 推荐(0)
摘要:link int dis[500][500]; int cost[500][500]; int pre[500]; int mindis[500]; int mincost[500]; int inque[500]; int main(){ memset(dis,-1,sizeof(dis)); i 阅读全文
posted @ 2020-05-08 08:52 feibilun 阅读(125) 评论(0) 推荐(0)
摘要:int main(){ int n; cin>>n; int bit=1; int res=0; while(true){ if(n/bit==0) break; int cur=n/bit%10; int high=n/bit/10; int low=n%bit; if(cur==0){ res+ 阅读全文
posted @ 2020-04-30 10:57 feibilun 阅读(93) 评论(0) 推荐(0)
摘要:link 1. Fenwick Tree: #include <iostream> #include <vector> #include <algorithm> #include <unordered_set> #include <cstring> #include <queue> #include 阅读全文
posted @ 2020-04-27 11:32 feibilun 阅读(103) 评论(0) 推荐(0)
摘要:link 解法: 只需要枚举质数能否整除n。提前筛除sqrt(n)以内的质数,然后到时候只需要枚举这些质数i能否整除n,若能整除,n=n/i;最后n必定是一个质数或是1。 #include <iostream> #include <vector> #include <algorithm> #incl 阅读全文
posted @ 2020-04-26 22:09 feibilun 阅读(118) 评论(0) 推荐(0)
摘要:link #include <iostream> #define LL long long using namespace std; int N,K; int nextadd[100000]; int val[100000]; int helper(int head){ int cur=head; 阅读全文
posted @ 2020-04-15 21:07 feibilun 阅读(108) 评论(0) 推荐(0)
摘要:link 常规写法: #include <iostream> #include <vector> #include <cstring> #include <stack> #include <unordered_set> #include <queue> #include <cmath> #defin 阅读全文
posted @ 2020-04-14 18:41 feibilun 阅读(187) 评论(0) 推荐(0)
摘要:link #include <bits/stdc++.h> # define LL long long using namespace std; int gettime(int hh, int mm, int ss){ return hh*3600+mm*60+ss; } struct Cartim 阅读全文
posted @ 2020-04-07 22:40 feibilun 阅读(150) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> # define LL long long using namespace std; int main(){ int N; cin>>N; int mx=0; int idx=0; for(int i=2;i<=sqrt(N);i++){ int t 阅读全文
posted @ 2020-04-06 13:57 feibilun 阅读(117) 评论(0) 推荐(0)
摘要: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]); } 阅读全文
posted @ 2020-03-24 19:35 feibilun 阅读(126) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-03-24 17:18 feibilun 阅读(98) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-03-24 15:32 feibilun 阅读(149) 评论(0) 推荐(0)
摘要: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>> 阅读全文
posted @ 2020-03-23 16:41 feibilun 阅读(96) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-03-19 19:11 feibilun 阅读(110) 评论(0) 推荐(0)
摘要:link 思路: 不可以bfs求最短路!因为到达中间点的最短路可能不唯一,无法取舍,而且中间点的选择会影响到后面点,必须全部考虑中间点的情况。 只能dfs了。 #include <iostream> #include <cstring> #include <vector> #include <uno 阅读全文
posted @ 2020-03-16 18:39 feibilun 阅读(131) 评论(0) 推荐(0)
摘要:link #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <set> #include <unordered_map> #include < 阅读全文
posted @ 2020-03-12 18:15 feibilun 阅读(128) 评论(0) 推荐(0)
摘要:link #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <set> #include <unordered_map> #include < 阅读全文
posted @ 2020-03-12 18:13 feibilun 阅读(120) 评论(0) 推荐(0)
摘要:link Dijkstra: #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstring> # define LL long long using namespace st 阅读全文
posted @ 2020-03-10 18:25 feibilun 阅读(170) 评论(0) 推荐(0)