STL || Gym 101653U Top 25
一组字符串给出两种排列方式,
求最小分成多少组 如
A A
B C
C D
D B
E E
则分成3组
A
B C D
E
即为1 3 1
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
map <string, int> maps;
int main()
{
int T;
cin >> T;
while(T--)
{
int n;
//char s[11];
cin >> n;
maps.clear();
string s;
for(int i = ; i < n; i++)
{
cin >> s;
//maps.insert(pair<string, int>(s, i));
maps[s] = i;//map把一个s和i对应起来
}
int ans = , idx = ;
for(int i = ; i < n; i++)
{
cin >> s;
/*map<string, int>::iterator iter;
iter = maps.find(s);
int t = iter -> second;*/
int t = maps[s];
idx = max(idx, t);
ans++;
if(idx == i) printf("%d ", ans), ans = ;
}
printf("\n");
}
return ;
}
STL || Gym 101653U Top 25的更多相关文章
- .NET开源项目 TOP 25
.NET开源项目 TOP 25 如果知道.NET项目在开源中国的git上所占的比重只有5%的话,为什么这个<2014年国人开发的最热门的开源软件TOP 100>榜中.NET项目那么少就是情 ...
- Top 25 Most Frequently Asked Interview Core Java Interview Questions And Answers
We are sharing 25 java interview questions , these questions are frequently asked by the recruiters. ...
- 2014年国人开发的最热门的.NET开源项目 TOP 25
原文地址:http://www.cnphp6.com/archives/72213 1 奎宇工作室 / DotNetCodes C# 一些常用的功能性代码,可以减少许多开发时间,而且类与类之间没有什么 ...
- 【面试】Spring问答Top 25
本文由 ImportNew - 一直在路上 翻译自 howtodoinjava.欢迎加入翻译小组.转载请见文末要求. 本人收集了一些在大家在面试时被经常问及的关于Spring的主要问题,这些问题有可能 ...
- Spring面试问答Top 25
欢迎大家向我推荐你在面试过程中遇到关于Spring的问题. 我会把大家推荐的问题加入到以下的Spring经常使用面试题清单中供大家參考. 问题清单: 什么是Spring框架?Spring框架有哪些主要 ...
- Python 面试问答 Top 25
Python 是一种解释型,交互式,面向对象的高级编程语言.和别的一些使用标点符号的语言不同,Pythons使用了大量的英语单词作为关键字,因而具有很好的可读性.而且跟其他编程语言相比,它有更少的语法 ...
- Top 10 Universities for Artificial Intelligence
1. Massachusetts Institute of Technology, Cambridge, MA Massachusetts Institute of Technology is a p ...
- 25 highest paying companies: Which tech co outranks Google, Facebook and Microsoft?
Tech companies dominate Glassdoor’s ranking of the highest paying companies in the U.S., snagging 20 ...
- .offset().top是什么意思?
offset获取匹配元素在当前视口的相对偏移: 返回的对象包含两个整形属性:top,left.此方法只对 可见元素有效. $("#div").offset() 获得位移对象:(此时 ...
随机推荐
- py-day15_css+js_初
css+js_初 一.鼠标移动变色 <!DOCTYPE html> <html lang="en"> <head> <meta chars ...
- 查看mysql状态
命令:mysqladmin -uroot -p -h172.16.0.20 status Uptime: 14317755 Threads: 61 Questions: 187732924 Sl ...
- HDU 5882 Balanced Game (水题)
题意:问 nnn 个手势的石头剪刀布游戏是否能保证出每种手势胜率都一样. 析:当每种手势的攻防个数完全相等才能保证平衡,所以容易得出 nnn 是奇数时游戏平衡,否则不平衡. 也就是说打败 i 的和 i ...
- hdoj3183【思维】
思路: 处理方案非常霸气啊,无奈想不到. 说是n位去m个,那么默认就是取了n-m个数字,ok,然后m #include <iostream> #include <stdio.h> ...
- c# dynamic 无法创建 泛型变量的问题
IMyClass<T> FunctionA<T>( object arg_obj) { dynamic dyObj = arg_obj; return new MyClass& ...
- vim normal 模式下L键
vim normal 模式下L键总是到一行的最后一个字符,而不是最后一个字符的下一个字符,这样进入插入模式,就还得往右移动一下,就很费劲? 怎么解决 更新: a键进入插入即可
- macOS 设置Root密码
用管理员帐号进入Terminal: 1) 输入:sudo passwd root ,回车: 2) 输入新的root密码: 3) 输入:su : 4) 输入新密码: 这样就进入到root帐号了.
- div 四周都有阴影的写法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- jquery选择器 选择除当前点击元素外所有的元素
问题: 多个select选择,如果已选择某些value ,该value不可再选 思路: 点击当前元素,js列出除当前元素外所有的元素 当前解决办法: function symbolDefine(ob ...
- discuz x2.5用户注册后邮箱认证后无法收到邮件或者直接进垃圾箱
又是一个周末,jquery特效继续折腾我那discuz论坛,我开启了个邮箱验证,恶意注册的太恶心了,没有办法. 能稍微屏蔽点,但是问题来了,据亲们反应,无法收到验证邮件,或者有时间直接进入垃圾箱,这个 ...