模拟水题之unique两行AC
https://icpc.njust.edu.cn/Contest/749/A/
Description
Input
Output
Sample Input
2
rrrjj
rrrj
rj
jr
Sample Output
Yes
No
Hint
题目中的第一个样例:第一盒糖果:rrrjj -> rrjj -> rjj -> rj第二盒糖果:rrrj -> rrj -> rj
题目大意很直白 突然想到有unique实现 但是对unique的理解不太太深 导致CE
#include<cstdio>
#include<map>
//#include<bits/stdc++.h>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<climits>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
string a,b;
cin>>a>>b;
a.erase(unique(a.begin(), a.end()), a.end());
b.erase(unique(b.begin(), b.end()), b.end());
if(a==b)puts("Yes");
else puts("No");
}
return ;
}
AC代码
需要注意的是unique并不是真正意义上的消去重复 只能移动相邻相同的到尾部 并返回尾部地址
如果只要消去后的
我们可以使用erase 或者尾部地址-vector数组首地址得到长度
如果想把数组中所有重复的消去 则需要sort 然后相同的都变为相邻的 就可以实现啦
unique真的是个神奇的东西
模拟水题之unique两行AC的更多相关文章
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- 模拟水题,查看二维数组是否有一列都为1(POJ2864)
题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...
- UVA 10714 Ants 蚂蚁 贪心+模拟 水题
题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
- HDU4287-STL模拟水题
一场2012天津网络预选赛的题,签到题. 但是还是写了三四十分钟,C++和STL太不熟悉了,总是编译错误不知道怎么解决. 一开始用的Char [] 后来改成了string,STL和string搭配起来 ...
- hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...
- Reversing Encryption(模拟水题)
A string ss of length nn can be encrypted(加密) by the following algorithm: iterate(迭代) over all divis ...
- Mishka and Contest(模拟水题)
Mishka started participating in a programming contest. There are nn problems in the contest. Mishka' ...
随机推荐
- 3.7-3.10 Hive 企业使用优化1
一.Fetch Task 在执行hive代码的时候,一条简单的命令大部分都会转换成为mr代码在后台执行, 但是有时候我们仅仅只是想获取一部分数据而已,仅仅是获取数据,还需要转化成为mr去执行吗? 那个 ...
- ASP.NET Core会议管理平台实战_1、开篇介绍
用到四个数据库
- 把myeclipse中html/jsp文件的视图调到只看代码
烦恼———————————————————— 解决方法: ok---------------------------- *.jsp 同理
- Unity3D调用摄像头,画面为翻转的问题
http://blog.csdn.net/a117653909/article/details/16119907 Unity3D中新建一个工程,加一个Plane,新建一个C# 脚本,调用摄像头,不过显 ...
- Unity NGUI学习
环境 Unity4.3 NGUI v3.68 导入 Project界面->右键->import package->custom package载入安装包即可 untiy4.6用 ...
- Aufree/trip-to-iOS
https://github.com/Aufree/trip-to-iOS?utm_source=next.36kr.com
- java排序之冒泡排序
代码: package com.cn.algorithm_arithmetic算法; /** * 本程序记录了经典排序算法之冒泡排序 * @author Administrator * */ publ ...
- scrapy框架的命令行解释
scrapy框架的命令解释 创建爬虫项目 scrapy startproject 项目名例子如下: scrapy startproject test1 这个时候爬虫的目录结构就已经创建完成了,目录结构 ...
- [51Nod1952] 栈
Description 不支持后端删除的dequeue,每次操作后查询最大值. \(n\leq10^7\).时限1.5s,不用考虑读入/输出复杂度. Solution 首先考虑如果没有后端删除怎么做, ...
- Codeforces Round #388 (Div. 2) D
There are n people taking part in auction today. The rules of auction are classical. There were n bi ...