经典的树分治,找字符串用hash找就行了….
#include
using namespace std;
typedef long long LL;
#define mp(x, y) make_pair(x, y)
const int maxn = 10005;
const int maxm = 20005;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const LL x = 1e6+3;
struct Edge
{
int v;
Edge *next;
}*H[maxn], *edges, E[maxm];
vector > dis;
bool isp[maxn];
bool iss[maxn];
int pre[maxn];
int suf[maxn];
char s[maxn];
char a[maxn];
bool done[maxn];
int size[maxn];
int mx[maxn];
LL xp[maxn];
int n, root, nsize, ans, ml;
LL powmod(LL a, LL b)
{
LL res = 1, base = a;
while(b) {
if(b % 2) res = res * base % mod;
base = base * base % mod;
b /= 2;
}
return res;
}
void addedges(int u, int v)
{
edges->v = v;
edges->next = H[u];
H[u] = edges++;
}
void init()
{
edges = E;
memset(H, 0, sizeof H);
memset(isp, 0, sizeof isp);
memset(iss, 0, sizeof iss);
memset(done, 0, sizeof done);
}
void getroot(int u, int fa)
{
mx[u] = 0, size[u] = 1;
for(Edge *e = H[u]; e; e = e->next) if(!done[e->v] && e->v != fa) {
int v = e->v;
getroot(v, u);
size[u] += size[v];
mx[u] = max(mx[u], size[v]);
}
mx[u] = max(mx[u], nsize - size[u]);
if(mx[u] ml) return;
dis.push_back(mp(dist, dep));
for(Edge *e = H[u]; e; e = e->next) if(e->v != fa && !done[e->v]) {
int v = e->v;
getdis(v, u, dep + 1, (dist + xp[dep] * (a[v]) % mod) % mod);
}
}
void solve(int u)
{
if(ans) return;
done[u] = true;
int t = a[u];
if(t == pre[1]) isp[1] = true;
if(t == suf[ml]) iss[ml] = true;
if(ml == 1 && t == pre[1]) ans = 1;
for(Edge *e = H[u]; e; e = e->next) if(!done[e->v]) {
int v = e->v;
dis.clear();
getdis(v, v, 1, a[v]);
for(int i = 0; i next) if(!done[e->v]) {
int v = e->v;
dis.clear();
getdis(v, v, 1, a[v] );
for(int i = 0; i next) if(!done[e->v]) {
int v = e->v;
mx[0] = nsize = size[v];
getroot(v, root = 0);
solve(root);
}
}
void work()
{
int u, v;
scanf("%d", &n);
for(int i = 1; i = 1; i--) suf[i] = (suf[i+1] * x + s[i]) % mod;
ans = 0;
mx[0] = nsize = n;
getroot(1, root = 0);
solve(root);
if(ans == 1) printf("Findn");
else printf("Impossiblen");
}
int main()
{
xp[0] = 1;
for(int i = 1; i
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.fwqtg.net
相关推荐: OData WebAPI实践-兼容OData集合响应
本文属于 OData 系列文章 引言 OData 是一个开放标准,已经在 oasis 组织标准化,因此我们可以在标准的官网查询到 OData 的标准请求与返回形式:OData JSON Format Version 4.01 (oasis-open.org) …