https://vjudge.net/problem/CodeChef-TAPAIR 合法的删除方法: 第一种:桥边与其余任意边(1)桥*(桥-1)/2(两条桥边)(2)桥*(m-桥)(桥边+其他边)第二种:两条非桥边:一定在同一个边双内对每一个边双求dfs树(1)两条树边(定义覆盖:反向边(a,b)覆盖了dfs树上a到b路径中每一条边)显然,任意边覆盖的路径中都是深度递减/递增的一些点如果两条树边被完全相同的边集覆盖,那么显然(感性理解)它们处在相同的环的中,因此同时去掉能让这些环断开两个口子…
传送门 题意:给出一个$N$个点.$M$条边的无向连通图,求有多少组无序数对$(i,j)$满足:割掉第$i$条边与第$j$条边之后,图变为不连通.$N \leq 10^5 , M \leq 3 \times 10^5$ 竟然随机化,歪果仁的思想好灵活qwq肯定是数据结构做多了 看起来很像割边,考虑$tarjan$,但是边三连通分量并不是很好实现,而且有很多特殊情况需要判断,所以我们考虑另外的算法 考虑$tarjan$时建出的一棵树.对于它来说,在一个端点在其下方.另一个端点在其上方的的返祖边可以…
GAME SPEC: 2-deck, 104 cards total. Bellagio has 2-deck and 6-deck games. based on hard 17, dealer has to draw cards if deal’s hand is less than 17. Soft 17 will slightly improve dealer’s advantage. FACE-UP, players are able to see each other’s card…
One-Way Streets (oneway) 题目描述 Once upon a time there was a country with nn cities and mm bidirectional roads connecting  them. Technical development led to faster and larger road vehicles which presented a problem-the roads were becoming too narrow f…
Counting on a directed graph Problem Code: GRAPHCNT All submissions for this problem are available. Read problems statements in Mandarin Chineseand Russian. Given an directed graph with N nodes (numbered from 1 to N) and M edges, calculate the number…
51nod 1290 Counting Diff Pairs | 莫队 树状数组 题面 一个长度为N的正整数数组A,给出一个数K以及Q个查询,每个查询包含2个数l和r,对于每个查询输出从A[i]到A[j]中,有多少对数,abs(A[i] - A[j]) <= K(abs表示绝对值). 题解 莫队!//其实我就是搜索"51nod + 莫队"找到的这道题-- 七级算法题! 一道320分! 你值得拥有! 题解就是--用个普通的莫队,加上树状数组来统计符合条件的数个数,就好啦. 当增加/…
一个长度为N的正整数数组A,给出一个数K以及Q个查询,每个查询包含2个数l和r,对于每个查询输出从A[i]到A[j]中,有多少对数,abs(A[i] - A[j]) <= K(abs表示绝对值). Input 第1行:3个数N,K,Q,中间用空格分隔,N为数组A的长度,K为差距,Q为查询的数量.(2 <= N <= 50000, 0 <= K <= 10^9, 1 <= Q <= 50000) 第2至N + 1行:每行1个数,对应数组中的数(1 <= A[i…
传送门--Vjudge 第一问很氵,如果\(K,N\)同奇偶就是\(2^K-1\),否则就是\(2^K-2\) 第二问似乎是可重排列,考虑指数型生成函数. 如何限制某些数必须要出现奇数/偶数次?考虑\(\frac{e^x-e^{-x}}{2}\),可以发现它的展开式中只有次数为奇数的项有值,而\(\frac{e^x+e^{-x}}{2}\)只有次数为偶数的项有值. 于是当\(K,N\)同奇偶时答案是\(N!(\frac{e^x-e^{-x}}{2})^K\),否则是\(N!(\frac{e^x-…
SADPAIRS 删点不连通,点双,圆方树 非割点:没有影响 割点:子树DP一下 有不同颜色,所以建立虚树 在圆方树上dfs时候 如果当前点是割点 1.统计当前颜色虚树上的不连通点对,树形DP即可 2.统计所有颜色的虚树上的不连通点对.... 一个麻烦事是,虚树上一条边上选择一个原树割点,都会对这个虚树造成相同的影响(两边sz乘积) n,m 2e5 树上差分 设虚树上,(x,y)的边,x是y的父亲 原树上,x的位置减去贡献,y的原树father位置加上贡献 最后dfs扫一遍就行了. 实际上麻烦事…
Description 求区间内有多少对 \((i,j)\) 满足 \(|a_i - a_j| \leq k\) Solution 可以莫队做(万能的莫队) 只需要考虑加入一个数会产生多少贡献即可 离散化的时候把 \(a_i,a_i - k, a_i+k\) 全部放进去. 加入一个数的时候只需要维护 \([a_i - k,a_i+k]\) 有多少个数,并且把 \(a_i\) 这个位置加上 1 删除亦然.这个可以用树状数组方便地维护. 具体实现的时候,因为树状数组是 sum(r) - sum(l-…
vjudge 首先显然要建立圆方树 对于每一种点建立虚树,考虑这一种点贡献,对于虚树上已经有的点就直接算 否则对虚树上的一条边 \((u, v)\),\(u\) 为父亲,假设上面连通块大小为 \(x\),下面为 \(y\) 切断 \((u, v)\) 之间的点(不包括 \(u\))都会有 \(x\times y\) 的贡献,差分一下贡献即可 # include <bits/stdc++.h> using namespace std; typedef long long ll; namespac…
 题意 给你一棵由 N 个节点构成的树 T.节点按照 1 到 N 编号,每个节点要么是白色,要么是黑色.有 Q 组询问,每组询问形如 (s, b).你需要检查是否存在一个连通子图,其大小恰好是 s,并且包含恰好 b 个黑色节点. 数据 输入第一行,包含一个整数 T,表示测试数据组数.对于每组测试数据: 第一行包含两个整数 N 和 Q,分别表示树的节点个数和询问个数. 接下来 N - 1 行,每行包含两个整数 ui 和 vi,表示在树中 ui 和 vi 之间存在一条边. 接下来一行包含 N 个整数…
难度 \(medium-hard\) 题意 官方中文题意 做法 很显然是可以通过计算常数个\(sum(A,B)=\sum\limits_{i=0}^A \sum\limits_{j=0}^B score(i,j)\) 结论1:\(score(i,j)\)为\(i,j\)数位拆分后排序的状态 暴力分类讨论或打表可得,不详述 设\(E\)为两数分数期望 则\(sum(A,B)=(A+1)(B+1)E\) 设\(x_{ij},y_{ij}\)分别为第一个数和第二个数排序后第\(i\)位为\(j\)的概…
难度 \(hard\) 题意 官方中文题意 做法 为避免数重,强制每维至少有一个\(0\),这个可以简单容斥 直径恰好为\(d\),不好求,也容斥一下…
Calculating Stereo Pairs Written by Paul BourkeJuly 1999 Introduction The following discusses computer based generation of stereo pairs as used to create a perception of depth. Such depth perception can be useful in many fields, for example, scientif…
Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. You need to return the number of important reverse pairs in the given array. Example1: Input: [1,3,2,3,1] Output: 2  Example2: Input: [2,4,3,5,1] Output:…
H. Path Counting time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output You are given a rooted tree. Let's denote d(x) as depth of node x: depth of the root is 1, depth of any other node x is d(y…
本文重点: 和一般形式的文本处理方式一样,并没有特别大的差异,文章的重点在于提出了一个相似度矩阵 计算过程介绍: query和document中的首先通过word embedding处理后获得对应的表示矩阵 利用CNN网络进行处理获得各自的feature map,接着pooling后获得query对应的向量表示Xq和document的向量Xd 不同于传统的Siamense网络在这一步利用欧式距离或余弦距离直接对Xq和Xd进行相似性计算后预测结果,网络采用一个相似矩阵来计算Xq和Xd的相似度,然后…
Problem Description Little A is an astronomy lover, and he has found that the sky was so beautiful!So he is counting stars now!There are n stars in the sky, and little A has connected them by m non-directional edges.It is guranteed that no edges conn…
C. Foe Pairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a permutation p of length n. Also you are given m foe pairs (ai, bi)(1 ≤ ai, bi ≤ n, ai ≠ bi). Your task is to cou…
Problem Description Little A is an astronomy lover, and he has found that the sky was so beautiful! So he is counting stars now! There are n stars in the sky, and little A has connected them by m non-directional edges. It is guranteed that no edges c…
Counting Pair Time Limit: 1000 ms Memory Limit: 65535 kB Solved: 112 Tried: 1209 Submit Status Best Solution Back Description   Bob hosts a party and invites N boys and M girls. He gives every boy here a unique number Ni(1 <= Ni <= N). And for the g…
C. Foe Pairs 题目连接: http://www.codeforces.com/contest/652/problem/C Description You are given a permutation p of length n. Also you are given m foe pairs (ai, bi) (1 ≤ ai, bi ≤ n, ai ≠ bi). Your task is to count the number of different intervals (x, y…
In this challenge you need to print the data that accompanies each integer in a list. In addition, if two strings have the same integers, you need to print the strings in their original order. Hence, your sorting algorithm should be stable, i.e. the…
Important Sisters Time Limit: 7000/7000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 766    Accepted Submission(s): 192 Problem Description There are N clones of Misaka Mikoto (sisters) forming the Misaka networ…
Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. You need to return the number of important reverse pairs in the given array. Example1: Input: [1,3,2,3,1] Output: 2 Example2: Input: [2,4,3,5,1] Output:…
题目链接: C. Foe Pairs time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   You are given a permutation p of length n. Also you are given m foe pairs (ai, bi) (1 ≤ ai, bi ≤ n, ai ≠ bi). Your task…
第二弾が始まる! codechef problems 第二弹 一.Backup Functions 题面 One unavoidable problem with running a restaurant is that occasionally a menu item cannot be prepared. This can be caused by a variety of reasons such as missing ingredients or malfunctioning equip…
For Developers‎ > ‎Coding Style‎ > ‎ Important Abstractions and Data Structures 目录 1 TaskRunner & SequencedTaskRunner & SingleThreadTaskRunner 2 MessageLoop & MessageLoopProxy & BrowserThread & RunLoop 3 base::SequencedWorkerPool…
Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. You need to return the number of important reverse pairs in the given array. Example1: Input: [1,3,2,3,1] Output: 2 Example2: Input: [2,4,3,5,1] Output:…