1941. Scary Martian Word

Source: Internet
Author: User

1941. Scary Martian Word

The problem is that a 3-length string is considered a Martian letter (ASCII 33-122), giving a word that Mars believes is scary (made up of the Martian alphabet)

And then I'll give you an article asking the number of words the Martians think is scary (can be ordered)

Well, at first test instructions understand wrong ... And then it's wrong.

God said ... is a double-ended queue

And then I wrote it and I felt really right about it.

Well, overconfidence, the beginning ignores a condition.

Practice, because it's three words 122+122*10+122*100 is almost there.

Then hash. Array tags,

Too lazy to write ...

Paste code ...

#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 namespaceStd;typedefLong Longll;Const DoubleESP = 10e-8;Const intMAXN =2000000+Ten;intVIS[MAXN];intNUM[MAXN];intARR[MAXN];intN;Charword[maxn*3+1];intMain () {//freopen ("Input.txt", "R", stdin);    intAns =0; memset (num,0,sizeof(num)); N=0;    Gets (word); intLen =strlen (word);  for(inti =0; I < len;i+=4){        inttt = (word[i]- -) + (word[i+1]- -)*Ten+ (word[i+2]- -)* -; NUM[TT]++; if(Num[tt] = =1) {n++;    }} gets (word); Len=strlen (word); memset (arr,-1,sizeof(arr)); intCNT =0;  for(inti =0; I < len;i+=4){        inttt = (word[i]- -) + (word[i+1]- -)*Ten+ (word[i+2]- -)* -; if(Num[tt]) {arr[cnt++] =tt; }    }    intL =0; intR =0; memset (Vis,0,sizeof(VIS)); intnn =0;  while(L < CNT && R <CNT) {        if(Arr[r]! =-1) {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=0; memset (Vis,0,sizeof(VIS)); R++; L=R; }} printf ("%d\n", ans); return 0;}

Do not write the comments are really not good programmers ...

1941. Scary Martian Word

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.