您现在的位置是:主页 > news > 单页网站怎么制作/比百度还强大的搜索引擎

单页网站怎么制作/比百度还强大的搜索引擎

admin2025/6/20 20:21:15news

简介单页网站怎么制作,比百度还强大的搜索引擎,做中医诊所网站,做网站如何大网页题目大意:   给你一串仅包含JOI的字符串,问满足三种字符出现次数相等的最大字串是多少? 思路:   用map存一下出现次数前缀和两两之差出现的最早位置,每次看一下当前的两两之差最早的出现位置是多少。 1 #include&…

单页网站怎么制作,比百度还强大的搜索引擎,做中医诊所网站,做网站如何大网页题目大意:   给你一串仅包含JOI的字符串,问满足三种字符出现次数相等的最大字串是多少? 思路:   用map存一下出现次数前缀和两两之差出现的最早位置,每次看一下当前的两两之差最早的出现位置是多少。 1 #include&…

题目大意:
  给你一串仅包含'J''O''I'的字符串,问满足三种字符出现次数相等的最大字串是多少?

思路:
  用map存一下出现次数前缀和两两之差出现的最早位置,每次看一下当前的两两之差最早的出现位置是多少。

 1 #include<map>
 2 #include<cstdio>
 3 #include<cctype>
 4 inline int getint() {
 5     register char ch;
 6     while(!isdigit(ch=getchar()));
 7     register int x=ch^'0';
 8     while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
 9     return x;
10 }
11 inline char getalpha() {
12     register char ch;
13     while(!isalpha(ch=getchar()));
14     return ch;
15 }
16 std::map<std::pair<int,int>,int> map;
17 int main() {
18     const int n=getint();
19     int ans=0;
20     map[std::make_pair(0,0)]=0;
21     for(register int i=1,s[3]={0,0,0};i<=n;i++) {
22         char ch=getalpha();
23         if(ch=='J') s[0]++;
24         if(ch=='O') s[1]++;
25         if(ch=='I') s[2]++;
26         std::pair<int,int> p=std::make_pair(s[1]-s[0],s[2]-s[0]);
27         if(map.count(p)) {
28             ans=std::max(ans,i-map[p]);
29         } else {
30             map[p]=i;
31         }
32     }
33     printf("%d\n",ans);
34     return 0;
35 }

 

转载于:https://www.cnblogs.com/skylee03/p/8124783.html