CF154C.Double Profiles
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have been offered a job in a company developing a large social network. Your first task is connected with searching profiles that most probably belong to the same user.
The social network contains n registered profiles, numbered from 1 to n. Some pairs there are friends (the "friendship" relationship is mutual, that is, if i is friends with j, then j is also friends with i). Let's say that profiles i and j (i ≠ j) are doubles, if for any profile k (k ≠ i, k ≠ j) one of the two statements is true: either k is friends with i and j, or k isn't friends with either of them. Also, i and j can be friends or not be friends.
Your task is to count the number of different unordered pairs (i, j), such that the profiles i and j are doubles. Note that the pairs are unordered, that is, pairs (a, b) and (b, a) are considered identical.
你获得了一家开发大型社交网络公司的职位。你的第一项任务与搜索极有可能属于同一用户的个人资料相关。
该社交网络包含 n 个已注册的个人资料,编号从 1 到 n。其中某些个人资料对互为好友(“好友”关系是对称的,即若 i 是 j 的好友,则 j 也是 i 的好友)。我们称个人资料 i 和 j(其中 i=j)为双胞胎资料(doubles),当且仅当对任意个人资料 k(其中 k=i 且 k=j),以下两个命题中恰有一个成立:
- k 同时是 i 和 j 的好友;
- k 既不是 i 的好友,也不是 j 的好友。
注意,i 和 j 可以是好友,也可以不是好友。
你的任务是计算满足条件的不同无序对 (i,j) 的数量,使得个人资料 i 和 j 构成双胞胎资料。注意,这些对是无序的,即 (a,b) 和 (b,a) 被视为同一对。
输入格式
The first line contains two space-separated integers n and m (1 ≤ n ≤ 106, 0 ≤ m ≤ 106), — the number of profiles and the number of pairs of friends, correspondingly.
Next m lines contains descriptions of pairs of friends in the format "v u", where v and u (1 ≤ v, u ≤ n, v ≠ u) are numbers of profiles that are friends with each other. It is guaranteed that each unordered pair of friends occurs no more than once and no profile is friends with itself.
第一行包含两个以空格分隔的整数 n 和 m(1 ≤ n ≤ 106,0 ≤ m ≤ 106),分别表示用户资料的数量和朋友对的数量。
接下来的 m 行每行描述一对朋友,格式为“v u”,其中 v 和 u(1 ≤ v, u ≤ n,且 v = u)是互为朋友的两个用户资料的编号。保证每对无序朋友关系至多出现一次,且不存在用户资料与自身为朋友的情况。
输出格式
Print the single integer — the number of unordered pairs of profiles that are doubles.
Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the %I64d specificator.
输出一个整数——即互为“双胞胎”的用户档案无序对的数量。
在 C++ 中,请勿使用 %lld 格式说明符读取或写入 64 位整数。推荐使用 %I64d 格式说明符。
输入输出样例
输入#1
3 3 1 2 2 3 1 3
输出#1
3
输入#2
3 0
输出#2
3
输入#3
4 1 1 3
输出#3
2
说明/提示
In the first and second sample any two profiles are doubles.
In the third sample the doubles are pairs of profiles (1, 3) and (2, 4).
在第一和第二个样例中,任意两个档案都是重复的。
在第三个样例中,重复的档案对是 (1, 3) 和 (2, 4)。
输入解题思路,AI测评打分。不知道怎么写?