oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

cousins Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

cousins.html

Problem Description

Peanut has been visiting his relatives during Chinese New Year, but due to the lack of internet access, he got very bored. As such, he recorded down the names of his N cousins, which all happen to be lowercase strings of at most 10 characters.

He wonders to himself, how many distinct pairs of cousins have names which are anagrams of one another. An anagram is defined as two strings X and Y such that the letters in X can be rearranged to form Y.

Input

The first line of input will contain one integer, N.

The next N lines of input will contain one string each, representing the name of Peanut's ith cousin.

Output

The output should contain one line with one integer, the number of distinct pairs of cousins who have names that are anagrams of one another.

Limits

Subtask 1 (17%): 1 ≤ N ≤ 2000.

Subtask 2 (20%): 1 ≤ N ≤ 300000, the names will only consist of the letter 'a'.

Subtask 3 (21%): 1 ≤ N ≤ 300000, the names will only consist of the letters 'a' and 'b'.

Subtask 4 (42%): 1 ≤ N ≤ 300000.

Subtask 5 (0%): Sample Testcases

Sample Testcase 1

Input

6
a
aaa
aaa
a
aaa
aaaaa

Output

4

Sample Testcase 2

Input

4
anna
bradley
nana
dryable

Output

2

Tags

Sorting

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
117201s256MBMinimum
220201s256MBMinimum
321201s256MBMinimum
442801s256MBMinimum
5021s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o cousins -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.