Input file: tour.inOutput file: tour.outTime limit: 1 secondsMemory limit: 128 megabytes在美丽的比特镇一共有 n 个景区,编号依次为 1 到 n,它们之间通过若干条双向道路连接。Byteasar 慕名来到了比特镇 ...
分类:
其他好文 时间:
2017-09-03 18:45:24
阅读次数:
178
将权值排序,设权值x排序后在[l,r]出现,x在区间中出现k次,则用[l,l+k-1]为1,[l+k,r]为0来表示x的出现次数 用bitset表示可重集中每个元素的出现次数,用莫队处理出询问区间对应的bitset,通过取and后求1的个数得到答案 ...
分类:
其他好文 时间:
2017-08-23 10:21:41
阅读次数:
168
用莫队求出每个询问区间对应的bitset(表示每个权值是否出现过),对于加减可以用bitset移位后取and判断,对于乘法可以直接枚举约数 ...
分类:
其他好文 时间:
2017-08-23 10:15:48
阅读次数:
117
【模板】三维偏序 题目背景 这是一道模板题 可以使用bitset,CDQ分治,K-DTree等方式解决。 题目描述 有 nn 个元素,第 ii 个元素有 a_ia?i??、b_ib?i??、c_ic?i?? 三个属性,设 f(i)f(i) 表示满足 a_j \leq a_ia?j??≤a?i?? 且 ...
分类:
其他好文 时间:
2017-08-21 14:55:02
阅读次数:
135
Gigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negli ...
分类:
其他好文 时间:
2017-08-21 13:30:01
阅读次数:
173
Kosaraju算法,然後bitset優化 主要是學習一下自寫bitset的姿勢 #include<cstring> #include<algorithm> #include<cstdio> #include<cmath> #define rep(i,l,r) for(int i=l;i<=r;i+ ...
分类:
其他好文 时间:
2017-08-21 13:28:52
阅读次数:
150
题目大意:尽可能多地去掉一个有向无环图上的边,使得图的连通性不变。 思路:拓扑排序,然后倒序求出每个结点到出度为$0$的点的距离$d$,再倒序遍历每一个点$x$,以$d$为关键字对其出边降序排序,尝试加入每一条边,若加边之前两点已经连通,则说明这条边可以删去。可以用bitset维护图的连通性,注意原 ...
分类:
Web程序 时间:
2017-08-21 13:27:19
阅读次数:
194
You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’ to be ‘2’, or leave the ‘1’ there. Surly, you may get many differen ...
分类:
其他好文 时间:
2017-08-19 11:04:48
阅读次数:
126
1.1 C++ STL ? STL容器: set, map, vector, priority_queue, queue, stack, deque, bitset? STL算法: sort, unique, nth_element, reverse, rotate, next_permution, ...
分类:
其他好文 时间:
2017-08-18 20:41:24
阅读次数:
291
我bitset+二分未遂后就来用ExGCD了,然而这道题的时间复杂度还真是玄学...... 我们枚举m然后对每一对用ExGCD判解,我们只要满足在最小的一方死亡之前无解就可以了,对于怎么用,就是ax+by=c,在这里c是距离差,a是速度差,b是m,x是我们要的解,y随意。 时间复杂度O(m*n*n* ...
分类:
其他好文 时间:
2017-08-15 10:06:55
阅读次数:
106