12.反异或01串 - 蓝桥云课 (lanqiao.cn)
#include "bits/stdc++.h"
#define int long long
using namespace std;
char c[10000000];
char s[10000000];
int cnt,Ans,mr,mid;
int maxi;
int p[10000000],pre[10000000];
signed main()
{ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);scanf("%s",c+1);int n=strlen(c+1);s[++cnt]='~';s[++cnt]='#';for(int i=1;i<=n;i++)s[++cnt]=c[i],s[++cnt]='#';s[++cnt]='!';for(int i=1;i<=cnt;i++){pre[i]=pre[i-1];if(s[i]=='1')pre[i]++;if(i<=mr) p[i]=min(p[mid*2-i],mr-i+1);else p[i]=1;while(s[i+p[i]]==s[i-p[i]]) p[i]++;if(i+p[i]>mr) mr=i+p[i]-1,mid=i;if(s[i]!='1'&&pre[i]-pre[i-p[i]]>pre[maxi]-pre[maxi-p[maxi]])maxi=i;}int k=pre[cnt]-(pre[maxi]-pre[maxi-p[maxi]]);cout<<k;
}
0艺术与篮球 - 蓝桥云课 (lanqiao.cn)
#include <bits/stdc++.h>
#define int long long
using namespace std;
int cnt[12]={13,1,2,3,5,4,4,2,2,2};
int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int check(int year)
{if((year%4==0&&year%100!=0)||year%400==0)return 1;else return 0;
}
int getd(int year,int month)
{if(check(year)&&month==2)return days[month]+1;return days[month];
}
int getb(int date)
{int sum=0;while(date){sum+=cnt[date%10];date/=10;}return sum;
}
int cntt=0;
signed main()
{ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);for(int year=2000;year<=2024;year++){for(int month=1;month<=12;month++){for(int day=1;day<=getd(year,month);day++){int date=year*10000+month*100+day;if(getb(date)>50&&(date<=20240413))cntt++; }}}cout<<cntt;
}
2.拉马车 - 蓝桥云课 (lanqiao.cn)
#include <bits/stdc++.h>
#define int long long
using namespace std;
queue<char>q1,q2;
void fun()
{vector<char>v;bool flag=true;while(q1.size()!=0&&q2.size()!=0){if(flag){v.push_back(q1.front());if(count(v.begin(),v.end(),q1.front())==2){while(v.size()!=0){q1.push(v.back());v.pop_back();if(count(v.begin(),v.end(),q1.front())==0)break; }}elseflag=false;q1.pop();if(q1.empty()) return;}if(!flag){v.push_back(q2.front());if(count(v.begin(),v.end(),q2.front())==2){while(!v.empty()){q2.push(v.back());v.pop_back();if(count(v.begin(),v.end(),q2.front())==0) break;//拿走完结束}} else flag=true;q2.pop(); if(q2.empty()) return; } }
}
signed main()
{ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
string s1,s2;cin>>s1>>s2;for(int i=0;i<s1.length();i++){q1.push(s1[i]);q2.push(s2[i]);}fun();while(!q1.empty()){ cout<<q1.front();q1.pop();}while(!q2.empty()){cout<<q2.front();q2.pop();}}