c语言sscanf函数的用法是什么
276
2022-08-31
codeforces 420C. Bug in Code
a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y
The head of the company decided to choose two suspects and invite them to his office. Naturally, he should consider the coders' opinions. That's why the head wants to make such a choice that at least p of n
Note that even if some coder was chosen as a suspect, he can agree with the head's choice if he named the other chosen coder at the meeting.
Input
The first line contains integers n and p (3 ≤ n ≤ 3·105; 0 ≤ p ≤ n)
Each of the next n lines contains two integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of coders named by the i-th coder. It is guaranteed that xi ≠ i, yi ≠ i, xi ≠ yi.
Output
Print a single integer –– the number of possible two-suspect sets. Note that the order of the suspects doesn't matter, that is, sets (1, 2) и (2, 1)
Sample test(s)
Input
4 2 2 3 1 4 1 4 2 1
Output
6
Input
8 6 5 6 5 7 5 8 6 2 2 1 7 3 1 3 1 4
Output
1
贴一张图辅助说明:
设A和B被指认为嫌疑人的频度是agree[a],agree[b],被人同时认定是嫌疑人的频度是map(a,b),那么A和B影响的对数是P=agree[a]+agree[b]-map(a,b)。假如P>=k就算入结果中。为了快速统计结果,可以先放两个指针p, pp在排好序(从小到大)的agree数组左右两边,p每向右移动一位,pp不断向左移动,直到agree[p]+agree[pp] #include
发表评论
暂时没有评论,来抢沙发吧~