1941. Scary Martian Word
这道题 一个长度为3的字符串视为 一个 火星文 字母(ASCII 33-122) ,给出一个火星人认为恐怖的单词(由火星字母组成)
然后 给你一篇文章问你火星人认为恐怖的单词个数(可以乱序)
嗯,一开始题意理解错了。。。然后就错了
彬神说……是双端队列
然后写了,感觉自己真是对对对的……
嗯,过度自信,起始忽略了一个条件。
做法,因为是三个单词 122+122*10+122*100 也就差不多了
然后哈希。数组标记,
懒得写了……
贴代码……
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <sstream>
using namespace std;
typedef long long ll;
const double ESP = 10e-;
const int MAXN = + ; int vis[MAXN];
int num[MAXN];
int arr[MAXN];
int n;
char word[MAXN*+];
int main(){
// freopen("input.txt","r",stdin); int ans = ;
memset(num,,sizeof(num));
n = ;
gets(word);
int len = strlen(word);
for(int i = ;i < len;i+=){
int tt = (word[i]-) + (word[i+]-)*+(word[i+]-)*;
num[tt]++;
if(num[tt] == ){
n++;
}
}
gets(word);
len = strlen(word);
memset(arr,-,sizeof(arr));
int cnt = ;
for(int i = ;i < len;i+=){
int tt = (word[i]-) + (word[i+]-)*+(word[i+]-)*;
if(num[tt]){
arr[cnt++] = tt;
}
}
int l = ;
int r = ;
memset(vis,,sizeof(vis));
int nn = ;
while(l < cnt && r < cnt){
if(arr[r] != -){
vis[ arr[r] ]++;
if(vis[arr[r]] == num[arr[r] ]){
nn++;
}else if(vis[ arr[r] ] > num[ arr[r] ]){
while(l < cnt && arr[l] != arr[r]){
if(vis[arr[l] ] == num[arr[l] ]){
nn--;
}
vis[ arr[l] ]--;
l++;
}
vis[ arr[l]]--;
l++;
}
if(nn == n){
ans++;
vis[arr[l]]--;
nn--;
l++;
}
r++;
}else{
nn = ;
memset(vis,,sizeof(vis));
r++;
l = r;
}
}
printf("%d\n",ans);
return ;
}
不写注释的果然不是好程序员……
1941. Scary Martian Word的更多相关文章
- 哈希URAL 1941 - Scary Martian Word
A - Scary Martian Word Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I ...
- Codeforces 149 E. Martian Strings
正反两遍扩展KMP,维护公共长度为L时.出如今最左边和最右边的位置. . .. 然后枚举推断... E. Martian Strings time limit per test 2 seconds m ...
- xtu summer individual-4 D - Martian Strings
Martian Strings Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...
- Word/Excel 在线预览
前言 近日项目中做到一个功能,需要上传附件后能够在线预览.之前也没做过这类似的,于是乎就查找了相关资料,.net实现Office文件预览大概有这几种方式: ① 使用Microsoft的Office组件 ...
- C#中5步完成word文档打印的方法
在日常工作中,我们可能常常需要打印各种文件资料,比如word文档.对于编程员,应用程序中文档的打印是一项非常重要的功能,也一直是一个非常复杂的工作.特别是提到Web打印,这的确会很棘手.一般如果要想选 ...
- C# 给word文档添加水印
和PDF一样,在word中,水印也分为图片水印和文本水印,给文档添加图片水印可以使文档变得更为美观,更具有吸引力.文本水印则可以保护文档,提醒别人该文档是受版权保护的,不能随意抄袭.前面我分享了如何给 ...
- 获取打开的Word文档
using Word = Microsoft.Office.Interop.Word; int _getApplicationErrorCount=0; bool _isMsOffice = true ...
- How to accept Track changes in Microsoft Word 2010?
"Track changes" is wonderful and remarkable tool of Microsoft Word 2010. The feature allow ...
- C#将Word转换成PDF方法总结(基于Office和WPS两种方案)
有时候,我们需要在线上预览word文档,当然我们可以用NPOI抽出Word中的文字和表格,然后显示到网页上面,但是这样会丢失掉Word中原有的格式和图片.一个比较好的办法就是将word转换成pdf,然 ...
随机推荐
- [转] HTC:html组件
~~~不时会看到 用htc实现 hover, border-raius等效果,可以用来弥补IE6-8的不足.那么htc到底是什么呢? 1.摘要 本文在实例的基础上讨论了HTC(HTML Compone ...
- C语言中没有main函数生成可执行程序的几种方法
1.define预处理指令 这种方式很简单,只是简单地将main字符串用宏来代替,或者使用##拼接字符串.示例程序如下: #include <stdio.h> #define begin ...
- 2057 A + B Again
A + B Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- html5 学习笔记
一.ie8及以下对html5相关语义标签的支持 <!-[if lt IE9]> <script src="html5.js"></script> ...
- 树莓派deian的linux常用命令
Linux系统,这个强大的系统,现在树莓派也要用到.给大家普及一下. 那些常用的Linux命令 linux的文件结构 / 根目录下的目录 /bin /home /dev /usr /opt /et ...
- WPF中StringFormat 格式化 的用法
原文 WPF中StringFormat 格式化 的用法 网格用法 <my:DataGridTextColumn x:Name="PerformedDate" Header=& ...
- 数据库中操作XML(openXML)
最近公司项目需要在数据库中操作XML,因此系统的学习了一下 一.openxml的格式 OPENXML( idoc int [ in] , XPathnvarchar [ in ] , [ flags ...
- zk leader选举自动完成
server 1: [root@wx03 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /zook ...
- 微信平台接入Web页面功能接口(C#)
微信平台接入web页面功能接口 今年因工作需要,通过微信平台接入公司的Wap页面,回忆下,记录内容,方面以后使用. 1.成为开发者后,你才可以使用公众平台的开发功能.需要填写URL和ToKen,接口配 ...
- 对xml进行解析
1.要解析的xml文件 <?xml version="1.0" encoding="utf-8"?> <infos> <city ...