标签:
题目链接:http://hihocoder.com/problemset/problem/1366
题意:中文题
正着倒着存一遍,看看有几个出现了>1次,结果除以2
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int maxn = 50500; 5 char s[maxn], t[maxn]; 6 int n; 7 map<string, int> ok; 8 9 int main() { 10 //freopen("in", "r", stdin); 11 while(~scanf("%d", &n)) { 12 ok.clear(); 13 for(int i = 0; i < n; i++) { 14 scanf("%s", s); 15 int n = strlen(s); 16 memset(t, 0, sizeof(t)); 17 for(int j = n - 1; j >= 0; j--) t[n-j-1] = s[j]; 18 ok[s]++; ok[t]++; 19 } 20 int ret = 0;; 21 for(auto it : ok) if(it.second != 1) ret++; 22 printf("%d\n", ret/2); 23 } 24 return 0; 25 }
标签:
原文地址:http://www.cnblogs.com/kirai/p/5918138.html