1.set

 #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <list>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std; //ÿ¸öµ¥´ÊÖ»³öÏÖÒ»´Î,¼´Ò»¸öµ¥´ÊÖÁ¶àÓëÆäËüµ¥´ÊÅäºÏÒ»±é
set<string> f; int main()
{
string s,t;
long n;
long sum=;
scanf("%ld",&n);
while (n--)
{
cin>>s;
if (f.find(s)!=f.end())
sum++; t=s;
reverse(t.begin(),t.end());
f.insert(t);
}
printf("%lld\n",sum);
return ;
}

2.map

 #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <list>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std; map<string,long> f; int main()
{
string s,t;
long n;
long long sum=;
scanf("%ld",&n);
while (n--)
{
cin>>s;
t=s;
reverse(t.begin(),t.end());
sum=sum+(long long)f[t]*f[t];
f[s]++;
}
printf("%lld\n",sum);
return ;
}

hiho一下 第197周 逆序单词的更多相关文章

  1. HihoCoder1366 逆序单词(字典树)

    逆序单词 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 在英文中有很多逆序的单词,比如dog和god,evil和live等等. 现在给出一份包含N个单词的单词表,其中每 ...

  2. 逆序单词 HIhoCoder 1366 字典树

    逆序单词 HIhoCoder 1366 字典序 题意 在英文中有很多逆序的单词,比如dog和god,evil和live等等. 现在给出一份包含N个单词的单词表,其中每个单词只出现一次,请你找出其中有多 ...

  3. 程序设计入门——C语言 第1周编程练习 1逆序的三位数(5分)

    第1周编程练习 查看帮助 返回   第1周编程练习题,直到课程结束之前随时可以来做.在自己的IDE或编辑器中完成作业后,将源代码的全部内容拷贝.粘贴到题目的代码区,就可以提交,然后可以查看在线编译和运 ...

  4. 【C语言】写一个函数,实现字符串内单词逆序

    //写一个函数,实现字符串内单词逆序 //比如student a am i.逆序后i am a student. #include <stdio.h> #include <strin ...

  5. 网易云课堂_程序设计入门-C语言_第一周:简单的计算程序_1逆序的三位数

    1 逆序的三位数(5分) 题目内容: 程序每次读入一个正三位数,然后输出逆序的数字.注意,当输入的数字含有结尾的0时,输出不应带有前导的0.比如输入700,输出应该是7. 输入格式: 每个测试是一个3 ...

  6. 网易云课堂_C语言程序设计进阶_第5周:链表_1逆序输出的数列

    1 逆序输出的数列(10分) 题目内容: 你的程序会读入一系列的正整数,预先不知道正整数的数量,一旦读到-1,就表示输入结束.然后,按照和输入相反的顺序输出所读到的数字,不包括最后标识结束的-1. 输 ...

  7. HWOJ-字符串的逆序

    将一个字符串str的内容颠倒过来,并输出.str的长度不超过100个字符. 如:输入“I am a student”,输出“tneduts a ma I”. 输入参数: inputString:输入的 ...

  8. php实现 句子逆序(需求才是最好的老师)

    php实现 句子逆序(需求才是最好的老师) 一.总结 一句话总结:需求才是最好的老师. 1.str_split()和explode()的区别? explode — 使用一个字符串分割另一个字符串 3 ...

  9. java笔试之字符逆序(二)

    与字符逆序(一)不同,句子逆序,单词顺序.例如:I am a student 输出为student a am I. 想法:先字符串句子逆序,然后针对每个单词再逆序一遍. package test; i ...

随机推荐

  1. 03-matplotlib-折线图

    import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates ''' 折线图,用直线段将各数 ...

  2. nginx 在ubuntu上使用笔记(绑定域名)

    1. 重启nginx的两个语句: sudo service nginx restart sudo nginx -s reload 2. nginx配置文件路径: etc/nginx/ 尤其是 site ...

  3. SpringBoot初始教程之Redis集中式Session管理

    1.介绍 有关Session的管理方式这里就不再进行讨论,目前无非就是三种单机Session(基于单机内存,无法部署多台机器).基于Cookie(安全性差).基于全局的统一Session管理(redi ...

  4. Hibernate笔记③--集合映射、组合映射、联合主键、查询案例

    lazy 懒加载 默认为proxy   继承映射 discriminant column="type" type="string"   集合映射 生成表的语句: ...

  5. ssh框架配置数据源 数据库连接没有正常释放

    通过多天的改bug 对数据源这个东西了解多了..    我发现 spring+hibernate下  申请数据库连接是在一个action方法内  也就是说  action 里面有三个 service方 ...

  6. Unity3D游戏开发——编程实现游戏管理器

    本篇简介 本篇介绍了如何将上一篇的设计模式思想运用到实际的开发过程中. 脚本文件 (1)IGameManager:这个接口存在声明了一个属性(一个拥有getter函数的变量,属性的类型是Manager ...

  7. PAT 1053 住房空置率

    https://pintia.cn/problem-sets/994805260223102976/problems/994805273284165632 在不打扰居民的前提下,统计住房空置率的一种方 ...

  8. WPF string,color,brush之间的转换

    String转换成Color string-"ffffff" Color color = (Color)ColorConverter.ConvertFromString(strin ...

  9. 使用testng多线程来测试成交编号重复的问题

    1.首先编写一个测试用的 function CREATE OR REPLACE FUNCTION getDealmainNo_test(dealdate IN varchar2, productcod ...

  10. 钉钉开发c#帮助类 获取用户信息 DingHelper.cs

    using System;using System.Collections.Generic;using System.Configuration;using System.Linq;using Sys ...