mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-12-19 21:51:44 +00:00
Compare commits
No commits in common. "a288f0c5ecee049af8dbd0df6d2af0ba92ef69d0" and "f6d958f00ad5a2b31af1072acf415b577ed540a2" have entirely different histories.
a288f0c5ec
...
f6d958f00a
@ -1,57 +0,0 @@
|
|||||||
#include <algorithm>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <iostream>
|
|
||||||
#include <istream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
using ll = int64_t;
|
|
||||||
#define printf
|
|
||||||
const ll p=2014;
|
|
||||||
std::string s;
|
|
||||||
ll n;
|
|
||||||
std::vector<std::vector<ll>> dp;
|
|
||||||
|
|
||||||
static inline ll dfs(const ll l,const ll r){
|
|
||||||
struct S{
|
|
||||||
const ll &l,&r,&dp;
|
|
||||||
S(const ll&l,const ll&r,const ll&dp):l(l),r(r),dp(dp){
|
|
||||||
printf("dfs l=%lld, r=%lld, START\n",l,r);
|
|
||||||
}
|
|
||||||
~S(){
|
|
||||||
printf("dfs l=%lld, r=%lld, ret=%lld\n",l,r,dp);
|
|
||||||
}
|
|
||||||
}raii(l,r,dp[l][r]);
|
|
||||||
const ll nlen=r-l+1;
|
|
||||||
if(l>r)return 0;
|
|
||||||
if(dp[l][r])return dp[l][r];
|
|
||||||
dp[l][r]=1;
|
|
||||||
if(nlen<=2)return dp[l][r]=1;
|
|
||||||
for(ll i=l+1;i<=r;i++){
|
|
||||||
if(i-l==r-i+1)continue;
|
|
||||||
const ll clen=std::min(i-l,r-i+1);
|
|
||||||
if(i-l==1&&r-i+1==1)continue;
|
|
||||||
for(ll j=0;j<clen;j++){
|
|
||||||
if(s[l+j]!=s[i+j])goto nxt1;
|
|
||||||
}
|
|
||||||
dp[l][r]=((i-l>r-i+1?dfs(l, i-1):dfs(i, r))+dp[l][r])%p;
|
|
||||||
nxt1:;
|
|
||||||
for(ll j=0;j<clen;j++){
|
|
||||||
if(s[i-1-j]!=s[r-j])goto nxt2;
|
|
||||||
}
|
|
||||||
dp[l][r]=((i-l>r-i+1?dfs(l, i-1):dfs(i, r))+dp[l][r])%p;
|
|
||||||
nxt2:;
|
|
||||||
}
|
|
||||||
return dp[l][r];
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(){
|
|
||||||
std::iostream::sync_with_stdio(false);
|
|
||||||
std::cin.tie(nullptr);
|
|
||||||
|
|
||||||
std::cin>>s;
|
|
||||||
n=s.size();
|
|
||||||
s=' '+s;
|
|
||||||
dp.resize(n+1,std::vector<ll>(n+1));
|
|
||||||
std::cout<<(dfs(1,n)-1+p)%p<<"\n";
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
#include <cstdint>
|
|
||||||
#include <iostream>
|
|
||||||
#include <istream>
|
|
||||||
#include <vector>
|
|
||||||
using ll = int64_t;
|
|
||||||
|
|
||||||
ll n,m;
|
|
||||||
struct P{
|
|
||||||
ll u,v;
|
|
||||||
};
|
|
||||||
std::vector<std::vector<P>> a;
|
|
||||||
std::vector<ll> f;
|
|
||||||
|
|
||||||
int main(){
|
|
||||||
std::iostream::sync_with_stdio(false);
|
|
||||||
std::cin.tie(nullptr);
|
|
||||||
|
|
||||||
std::cin>>n>>m;
|
|
||||||
a.resize(n+1);
|
|
||||||
f.resize(n+1);
|
|
||||||
for(ll i=1;i<=m;i++){
|
|
||||||
ll u,v;
|
|
||||||
std::cin>>u>>v;
|
|
||||||
f[u]++,f[v]++;
|
|
||||||
a[u].emplace_back(v);
|
|
||||||
a[v].emplace_back(u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user