首页 > 其他 > 详细

[HIHO1366]逆序单词(水题)

时间:2016-09-29 01:11:10      阅读:179      评论:0      收藏:0      [点我收藏+]

题目链接: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 }

 

[HIHO1366]逆序单词(水题)

原文:http://www.cnblogs.com/kirai/p/5918138.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!