fix(test.cpp): 修正source_location的使用方式

feat(P7114.cpp): 添加字符串处理算法实现
This commit is contained in:
Zengtudor 2025-11-06 15:39:42 +08:00
parent abf764a938
commit e78435a306
2 changed files with 54 additions and 1 deletions

53
src/11/6/P7114.cpp Normal file
View File

@ -0,0 +1,53 @@
#include <bitset>
#include <cstdint>
#include <iostream>
#include <istream>
#include <map>
#include <string>
using ll = int64_t;
#define sl static inline
std::string s;
std::bitset<256> mcj,maj;
sl ll cj(){return mcj.count();}
sl ll aj(){return maj.count();}
sl void solve(){
ll ans=0;
mcj.reset();
maj.reset();
std::cin>>s;
for(ll alen=1;alen<s.size()-1;alen++){
maj[s[alen-1]]=maj[s[alen-1]]^1;
for(ll blen=1;alen+blen<s.size();blen++){
mcj.reset();
for(ll l=1;l*(alen+blen)<s.size();l++){
for(ll ci=l*(alen+blen);ci<s.size();ci++){
mcj[s[ci]]=mcj[s[ci]]^1;
}
if(aj()>cj()){
continue;
}
for(ll i=alen+blen;i<l*(alen+blen);i++){
if(s[i%(alen+blen)]!=s[i]){
goto nxt;
}
}
ans++;
nxt:;
}
}
}
std::cout<<ans<<"\n";
}
int main(){
std::iostream::sync_with_stdio(false);
std::cin.tie(nullptr);
ll t;
std::cin>>t;
while(t--){
solve();
}
}

View File

@ -2,5 +2,5 @@
#include <print>
#include <source_location>
int main(){
std::println("hello world from {}\n",std::source_location().file_name());
std::println("hello world from {}\n",std::source_location::current().file_name());
}