UVA - 156 Ananagrams ——STL练习

realsense D455深度相机+YOLO V5结合实现目标检测(一) realsense D455深度相机+YOLO V5结合实现目标检测代码来源环境配置代码分析:1.如何用realsense在python下面调用的问题:2.对main_debug.py文件的分析:结束语 可以实现将D435,D455深度相机和yolo v5结合到一起,在识别物体的同时,还能测到物体相对与相机的距离。 说明一下为什么需要做这个事情?1.首先为什么需要用到realsense D455深度相机? 因为他是普通的相机还加了一个红外测距的东西,所以其他二维图像一样,能够得到三维世界在二维像素平面的投影 阅读详情

Most crossword puzzle fans are used to anagrams — groups of words with the same letters in different
orders — for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this
attribute, no matter how you rearrange their letters, you cannot form another word. Such words are
called ananagrams, an example is QUIZ.
Obviously such definitions depend on the domain within which we are working; you might think
that ATHENE is an ananagram, whereas any chemist would quickly produce ETHANE. One possible
domain would be the entire English language, but this could lead to some problems. One could restrict
the domain to, say, Music, in which case SCALE becomes a relative ananagram (LACES is not in the
same domain) but NOTE is not since it can produce TONE.
Write a program that will read in the dictionary of a restricted domain and determine the relative
ananagrams. Note that single letter words are, ipso facto, relative ananagrams since they cannot be
“rearranged” at all. The dictionary will contain no more than 1000 words.

Input
Input will consist of a series of lines. No line will be more than 80 characters long, but may contain any
number of words. Words consist of up to 20 upper and/or lower case letters, and will not be broken
across lines. Spaces may appear freely around words, and at least one space separates multiple words
on the same line. Note that words that contain the same letters but of differing case are considered to
be anagrams of each other, thus ‘tIeD’ and ‘EdiT’ are anagrams. The file will be terminated by a line
consisting of a single ‘#’.
Output
Output will consist of a series of lines. Each line will consist of a single word that is a relative ananagram
in the input dictionary. Words must be output in lexicographic (case-sensitive) order. There will always
be at least one relative ananagram.
Sample Input
ladder came tape soon leader acme RIDE lone Dreis peat
ScAlE orb eye Rides dealer NotE derail LaCeS drIed
noel dire Disk mace Rob dries

Sample Output
Disk
NotE
derail
drIed
eye
ladder
soon


题目大意:
输入一些单词,按字典序顺序输出无视大小写及字母顺序后,只出现一次的单词。如 STOP、SOPT、spTO 算重复出现。


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

string change(string s)
{
    for(int i=0;i<s.size();i++)
        s[i]=tolower(s[i]);
    sort(s.begin(),s.end());//按字典序排列单词
    return s;
}
int main()
{
    string s;
    map<string ,int > p;//用来统计单词 change 后的次数
    vector<string> ans;//用来保存结果
    vector<string> ve;//用来保存原始单词,因为输出的时候就是原始单词
    while(cin>>s&&s!="#")
    {
        ve.push_back(s);
        p[change(s)]++;
    }
    for(int i=0;i<ve.size();i++)
        if(p[change(ve[i])]==1)//如果单词改变后只出现了一次,那就符合答案
            ans.push_back(ve[i]);
    sort(ans.begin(),ans.end());//排序,按字典序升序排列
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<endl;
    return 0;
}

或者

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5+7;
// ll a[MAXN];
struct node{
        int num;
        string s;
        node(){num=0;};//在结构体内部初始化值
        node(int _num, string _s)
        {
                num = _num;
                s = _s;
        }
};
int main()
{
        set<string> se;
        map<string,node> m;
        string str;
        while(cin>>str)
        {
                string c;
                if(str=="#")    break;
                for(int i=0;i<str.size();++i)
                        c += tolower(str[i]);
                sort(c.begin(),c.end());
                m[c] = node(m[c].num+1,str);
        }

        for(map<string,node>::iterator it=m.begin();it!=m.end();++it)
                if(it->second.num==1)   se.insert(it->second.s);
        for(set<string>::iterator it=se.begin();it!=se.end();it++)
                cout<<*it<<endl;
        return 0;
}

Rockchip eMMC寿命监控:SMART信息读取与预防性维护 擦写计数坏块数量温度使用时间。 阅读详情

相关推荐

Langfuse落地教程:从Docker部署到项目接入,掌控LLM调用链路

大模型应用开发中,调用链路的透明度直接决定调试效率与成本控制。可观测性技术通过记录每次请求的输入、输出、模型参数与Token消耗,帮助开发者快速定位问题。Langfuse作为开源LLM可观测性平台,将Trace、Prompt版本管理、评分等能力集成于一体,支持Docker Compose自托管部署,并提供Python/JS SDK与REST API。借助部署后的控制台,团队能够直观追踪RAG检索、Agent工具调用等复杂流程中的每一步耗时与资源占用,实现从黑盒调用到全链路可视化的转变。无论是本地调试、线上排

weixin_29698641的博客 308

Ananagrams(STL模板:map,set,vector的使用)

Most crossword puzzle fans are used toanagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this attribute, ...

Mr_Kingk的博客 330

CentOS Stream 9中安装MySQL的详细步骤

本文详细介绍了在CentOS Stream 9系统中如何进行MySQL的在线安装、离线安装以及忘记密码的恢复操作。通过阅读本文,您将能够了解并掌握在CentOS Stream 9上安装MySQL的步骤,以及在遇到忘记密码的情况下的解决方案。

小白典的博客 7258

Uva156:反片语Ananagrams(详解包看懂)

用map来判断单词重复次数即可完美解决这道题

帅到灭亡的博客 376

告别混乱接线!用EPLAN 3D布局图,手把手教你搞定电气柜的3D建模与自动布线

本文详细介绍了如何使用EPLAN 3D布局图进行电气柜的3D建模与自动布线,帮助工程师告别混乱接线。从项目准备、基础结构建模到智能设备布局与逻辑定义,再到高级布线技术与问题排查,提供了一套完整的实战指南。通过EPLAN的3D功能,显著提升设计效率与系统可靠性。

weixin_30680385的博客 340

Unsloth Desktop 本地大模型微调量化实战指南

大语言模型的本地化定制正在成为开发者与内容创作者的重要需求,而微调与量化则是其中最关键的两项技术。LoRA 与 QLoRA 通过仅训练少量低秩矩阵,大幅降低显存占用和训练成本,让消费级 GPU 也能完成模型适配;GGUF 格式则打通了训练与推理的边界,使微调后的模型可直接接入 Ollama、llama.cpp 等主流推理引擎。本文以 Unsloth Desktop 为切入对象,从其底层加速原理出发,梳理了环境准备、模型加载、对话测试、量化导出、微调验证及 API 批量调用的完整链路,并针对显存优化、端口冲突

weixin_29055137的博客 397

uva156 Ananagrams

uva156 回文 排序 映射

梵高先生的专栏 592

远程桌面连接失败?手把手教你解决CredSSP加密Oracle漏洞(Win10/Win11通用)

本文详细解析了Windows远程桌面连接因CredSSP加密Oracle漏洞安全更新导致的“身份验证错误”问题。文章从原理入手,提供了通过组策略编辑器(适用于专业版)和注册表编辑器(适用于家庭版)两种核心解决方案,指导用户将安全策略调整为推荐的“缓解”模式,以在保障安全的前提下恢复连接,并给出了高级脚本处理与安全最佳实践。

u6v7w8x的博客 724

uva 156 反片语

Description Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do not h...

lvzi的博客 238

从‘平行’到‘鱼骨’:手把手拆解AlGaN/GaN HEMT多栅指结构的布局优化实战

本文深入探讨了AlGaN/GaN HEMT多栅指结构的布局优化,从传统的平行栅结构到创新的鱼骨栅结构,详细解析了如何通过优化信号路径和热管理提升功率器件的性能。文章结合实测数据和EDA工具,展示了鱼骨栅结构在相位一致性、热阻和版图利用率方面的显著改进,为射频功率放大器设计提供了实用指导。

weixin_27061475的博客 441

从SVF文件到高效验证:Formality中set_svf命令的隐藏技巧与实战解析

本文深入解析Formality中set_svf命令的高级应用技巧,涵盖SVF文件生成策略、多文件加载优化及验证效率提升方法。通过-append和-ordered选项的实战应用,帮助工程师解决芯片验证中的常见问题,实现验证通过率与运行效率的双重提升。

mqtt6iot的博客 819

map()函数的应用详解

map()函数的应用详解

m0_53396342的博客 968

关于RTP时间戳以及播放器对时间戳的处理

首先,了解时间戳几个基本概念: 时间戳单位:时间戳计算的单位不是秒之类的单位,而是由采样频率所代替的单位,这样做的目的就是为了是时间戳单位更为精准。比如说一个音频的采样频率为8000Hz,那么我们可以把时间戳单位设为1 / 8000。 时间戳增量:相邻两帧之间的时间差(以时间戳单位为基准)。 采样频率: 有些地方也叫时钟频率,即 每秒钟抽取样本的次数,例如音频的采...

toshiba689的专栏 3052

UVa-156-Ananagrams STL map容器的使用练习题

题意:输入一些单词,找出所有满足如下条件的单词:单词不能通过排列得到输入中的另一个单词,在判读满足条件时不区分大小写,但输出时保留原串输出,按字典序输出(所有大写字母在小写字母前面) 本题是练习map用法的一道练习题 map容器是key-value对应的一种关联容器,即每个key对应一个value值 本题用到一些容器的基本操作,push_back(),insert()什么的,很方便,这就是S

三生锁链 680

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

UVa 156 Ananagrams

题目要求从字典中找出无法通过字母重排得到其他单词的"非变位词"。通过将每个单词转换为小写并排序作为标准化表示,统计出现次数为1的单词即为解。算法使用multiset统计频率,最后按字典序输出原始单词。时间复杂度为O(nklogn),空间复杂度O(nk),利用STL高效实现。

寂静山林 1079

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

2018.2.1【 UVA - 156 】解题报告(STL,set,multiset,make_pair)

原题链接:点击打开链接 【题目大意】 ananagrams,指一系列单词由相同的字母构成(但顺序不同),输入一段文章,将非ananagrams输出,即没有与他字母构成相同但顺序不同的单词。 【解题思路】 本题学习了UVa 156 Ananagrams (用STL multimap&set处理字典中的重复元素),这位前辈的代码。 思路即将每个单词s(处理后的状态)和origin(处理前状态

Eddy 329

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

uva 156 Ananagrams (STL)

Ananagrams   Most crossword puzzle fans are used to anagrams — groups of words with the same letters in different orders — for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have...

辞树 388

UVA156 Ananagrams

问题链接:UVA156 Ananagrams。 题意简述:输入一个文本文件,从中提取出一些单词输出,输出的单词按照文本文件中的原来样子输出(字母大小写不变)。对于所有的单词,若字母不分大小写,单词经过重排顺序,与其他单词相同,这些单词则不在输出之列。 问题分析:用C++语言编写程序,可以练习使用STL的功能。。另外一点,C++编写程序效率会更高。 程序说明:使用...

weixin_34077371的博客 136

uva 156 Ananagrams(字符串+STL应用)

uva 156 Ananagrams Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different orders--for example OPTS, SPOT, STOP, POTS and POST. Some words however do

总有那么一群人喜欢盯着我的博客看,估计这是他们见过最长的博客名,我必须得告诉他们博客名最长可以写多长 559

UVA156 Ananagrams【map+vector】

Most crossword puzzle fans are used to anagrams — groups of words with the same letters in different orders — for example OPTS, SPOT, STOP, POTS and POST. Some words however do not have this attribute...

海岛Blog 2023

UVA 156 Ananagrams(stl,map,set)

例题4:UVA 156 Ananagrams 题目:把每个单词全部转化成小写字母,对每个单词,看它的字母重排后得到的单词在所有输入的单词中是否出现过,若没有出现,就输出原单词。所有要输出的单词按字典序排列输出。 思路:先小写化,然后二维的string排个序,然后用map建立string与int的映射,然后hash一下再放到set里面排个序,其实不hash应该也可以,因为set本身就有去重的功能#

银之夏雪的博客 471

Uva 156 Ananagrams

#include #include #include #include #include #include #include #include using namespace std ; struct Node{ string str ; string num ; void Init(const char* str1) { str.clea

ZQDNR 429

UVA - 156 Ananagrams

解题思路:map的使用(STL) 解题代码:参考《算法入门经典》 #include&lt;iostream&gt; #include&lt;vector&gt; #include&lt;algorithm&gt; #include&lt;map&gt; using namespace std; map&lt;string,int&gt;cnt; vector&lt;string...

C/C++ 212

Uva 156 Ananagrams

Ananagrams Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description Most crossword puzzle fans are used to anagrams--groups

舒哥的blog 980

[UVA156]反片语 Ananagrams 题解(映射:map 详解)

[UVA156]反片语 Ananagrams 题解(映射:map 详解)map简介 map是STL的一个关联容器,它提供一对一的hash。 第一个可以称为关键字(key),每个关键字只能在map中出现一次; 第二个可以称为该关键字的值(value); map以模板(泛型)方式实现,可以存储任意类型的数据,包括使用者自定义的数据类型。Map主要用于资料一对一映射(one-to-one)的情況,map內部的实现自建一颗红黑树,这颗树具有对数据自动排序的功能。在map内部所有的数据都是有序的,后边我们会见识到

qq_73635134的博客 199

UVa 156 Ananagrams【STL-map】

https://vjudge.net/problem/UVA-156 map重载了[],就是键值对,map的使用方法与数组类似,但是下标变为了自定义的类型 map相关见https://zh.cppreference.com/w/cpp/container/map map<string,int> cnt; vector<string> words; string repr(...

之虎者也的博客 153
上一篇: Andy's First Dictionary UVA - 10815————STL练习
下一篇: {A} + {B} HDU - 1412——STL练习(set)
陶鸿杰
博客等级 码龄9年 93粉丝 298原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值