Submission details
Task:Anagrams
Sender:lnan95
Submission time:2020-09-26 13:30:12 +0300
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.12 sdetails
#2ACCEPTED0.69 sdetails
#3ACCEPTED0.23 sdetails
#4ACCEPTED0.76 sdetails
#5ACCEPTED0.71 sdetails
#6ACCEPTED0.67 sdetails
#7ACCEPTED0.01 sdetails
#8ACCEPTED0.01 sdetails
#9ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:21:29: warning: unused variable 'key' [-Wunused-variable]
   for (const auto &[key, val] : ma) {
                             ^

Code

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

map<string, vector<string>> ma ;
int n;
string str, str2;
int main() {
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> str;
    str2 = str;
    sort(str2.begin(), str2.end());
    ma[str2].emplace_back(move(str));
  }
  
  int z = count_if(ma.begin(), ma.end(), [](auto & v) {return v.second.size() > 1;});
  cout << z << endl;
  for (const auto &[key, val] : ma) {
    if (val.size() < 2) continue;
    cout << val.size() << endl;
    for (const auto &str : val) {
      cout << str << endl;
    }
  }
}

Test details

Test 1

Verdict: ACCEPTED

input
68760
aakkonen
aakkosellinen
aakkosellisesti
aakkosellisuus
...

correct output
3076
2
haaraantua
raahaantua
2
...

user output
3076
2
haaraantua
raahaantua
2
...
Truncated

Test 2

Verdict: ACCEPTED

input
370099
a
aa
aaa
aah
...

correct output
30178
2
basiparachromatin
marsipobranchiata
2
...

user output
30178
2
basiparachromatin
marsipobranchiata
2
...
Truncated

Test 3

Verdict: ACCEPTED

input
100000
cnhmuewgnum
dxkmhzhetnmxadtcy
hfjqwavsiguwpludsketibe
xwxolrmvkz
...

correct output
0

user output
0

Test 4

Verdict: ACCEPTED

input
400000
vlcsa
eltwde
wdcwwkubs
tmuxbirj
...

correct output
0

user output
0

Test 5

Verdict: ACCEPTED

input
400000
ebhfigdacjlk
aecfdijlhkgb
jfekhbidacgl
cehajbidfklg
...

correct output
1
400000
abcdeighjlfk
abcdeiglhfjk
abcdfkilejgh
...

user output
1
400000
ebhfigdacjlk
aecfdijlhkgb
jfekhbidacgl
...
Truncated

Test 6

Verdict: ACCEPTED

input
400000
cbaabghadefb
hbbgfaeabdac
abaedcbgfbha
hcfadbbbeaag
...

correct output
1
400000
aaabbbcfegdh
aaabbbcfghed
aaabbbdcgfhe
...

user output
1
400000
cbaabghadefb
hbbgfaeabdac
abaedcbgfbha
...
Truncated

Test 7

Verdict: ACCEPTED

input
1
a

correct output
0

user output
0

Test 8

Verdict: ACCEPTED

input
2
ab
ba

correct output
1
2
ab
ba

user output
1
2
ab
ba

Test 9

Verdict: ACCEPTED

input
2
aa
ab

correct output
0

user output
0