模拟水题之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' ...
随机推荐
- 微信小程序开发之页面跳转并携带参数
接口: wx.navigateTo({url:......}) 保留当前页面,跳转到应用内指定URL页面,导航栏左上角有返回按钮 wx.redirecTo({url:.....}) 关 ...
- 技术胖Flutter第三季-14布局RowWidget的详细讲解
flutter总的地址: https://jspang.com/page/freeVideo.html 视频地址: https://www.bilibili.com/video/av35800108/ ...
- msq 表操作与其数据类型
一:表介绍 表相当于文件, 表中的一条记录就相当于文件的一行内容, 不同的是,表中的一条记录有对应的标题,称为表的字段: id,name, age, sex,称为字段, 其余的一行内容称为一条记录. ...
- ASP.NET Response.Cookies
//设置cookie Response.Cookies["loginPage"].Value = "login.aspx"; //命名并给值 Response. ...
- 新装ubuntu 12.04 , 使用技巧
*********************************************** 一.让Ubuntu 12.04开机默认进入命令行模式. 修改 /etc/default/grubGRUB ...
- 关于MySQL集群架构优劣势与适用场景的分析与思考
http://blog.itpub.net/25723371/viewspace-1977389/
- cobian backup 11 使用
主机和备份机器创建备份用户(bf) 在备份机器上 设置备份用户, 备份目录右键安全,添加刚刚创建的备份bf用户,并授予所有权限 设置文件夹共享,并设置共享用户为刚刚创建的bf用户 并且在高级共享设置去 ...
- [題解]BZOJ_1260_塗色
簡單的區間dp,結果竟然寫掛了......還掛的很徹底......狗屎 如果區間左右端點相等,那麼不需要在多花一次去刷,對 f [ i+1 ] [ j ],f [ i ] [ j-1 ]取個min, ...
- Tourists Codeforces - 487E
https://codeforces.com/contest/487/problem/E http://uoj.ac/problem/30 显然割点走过去就走不回来了...可以看出题目跟点双有关 有一 ...
- Elasticsearch之安装
elasticsearch需要java8以上支持 java -version 二进制文件下载 www.elastic.co/downloads tar安装示例 1.下载tar文件 curl -L -O ...