Submission details
Task:Anagrams
Sender:lnan95
Submission time:2020-09-26 13:29:59 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:19:45: error: use of 'auto' in lambda parameter declaration only available with -std=c++14 or -std=gnu++14
   int z = count_if(ma.begin(), ma.end(), [](auto & v) {return v.second.size() > 1;});
                                             ^~~~
input/code.cpp: In lambda function:
input/code.cpp:19:65: error: request for member 'second' in 'v', which is of non-class type 'int'
   int z = count_if(ma.begin(), ma.end(), [](auto & v) {return v.second.size() > 1;});
                                                                 ^~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:21:20: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
   for (const auto &[key, val] : ma) {
                    ^
input/code.cpp:21:29: warning: unused variable 'key' [-Wunused-variable]
   for (const auto &[key, val] : ma) {
                             ^
In file included from /usr/include/c++/7/bits/stl_al...

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;
    }
  }
}