正文
增加 10 行删除 10 行
23 行未改动2425262728293031323334353618 行未改动55565758596061626364656613 行未改动8081828384858687886 行未改动95969798991001011021031041051061071081091101111121131141151161171187 行未改动23 行未改动```#include <bits/stdc++.h>using namespace std;const int mod = 1e9 + 7 , N = 1000 , M = 12;inline void add(int &x , int y) {x += y ; if(x >= mod) x -= mod;}inline void sub(int &x , int y) {x -= y ; if(x < 0) x += mod;}struct Tree : vector<vector<int>> {void AddEdge(int x , int y) {this->at(x).push_back(y) , this->at(y).push_back(x);}18 行未改动}}return x;}int Log2[1 << M];struct TreeMatcher {vector<int> dp[N][M];int dfs(Tree &S , Tree &T , int s , int t) {vector<int> &cur = dp[s][t];if(!cur.empty()) return cur.back();13 行未改动if(S.size() < T.size())return 0;if(T.size() <= 1)return S.size();auto clr = [&] {for(int i = 0 ; i < S.size() ; ++i)for(int j = 0 ; j < T.size() ; ++j) dp[i][j].clear();};6 行未改动add(ans , dfs(s , t , i , j));}return ans;}};inline int Inv(int x) {return x <= 1 ? x : 1LL * (mod - mod / x) * Inv(mod % x) % mod;}Tree S , T;TreeMatcher matcher;int main() {auto Input = [&](Tree &tree) {int n ;scanf("%d" , &n);tree.resize(n);for(int i = 1 , x , y ; i < n ; ++i) {scanf("%d %d" , &x , &y);tree.AddEdge(x - 1, y - 1);}7 行未改动23 行未改动2425262728293031323334353618 行未改动55565758596061626364656613 行未改动8081828384858687886 行未改动95969798991001011021031041051061071081091101111121131141151161171187 行未改动23 行未改动```#include <bits/stdc++.h>using namespace std;const int mod = 1e9 + 7 , N = 1000 , M = 12;inline void add(int &x , int y) {x += y ; if(x >= mod) x -= mod;}inline void sub(int &x , int y) {x -= y ; if(x < 0) x += mod;}struct Tree : vector<vector<int>> {void AddEdge(int x , int y) {this->at(x).push_back(y) , this->at(y).push_back(x);}18 行未改动}}return x;}int Log2[1 << M];struct TreeMatcher {vector<int> dp[N][M];int dfs(Tree &S , Tree &T , int s , int t) {vector<int> &cur = dp[s][t];if(!cur.empty()) return cur.back();13 行未改动if(S.size() < T.size())return 0;if(T.size() <= 1)return S.size();auto clr = [&] {for(int i = 0 ; i < S.size() ; ++i)for(int j = 0 ; j < T.size() ; ++j) dp[i][j].clear();};6 行未改动add(ans , dfs(s , t , i , j));}return ans;}};inline int Inv(int x) {return x <= 1 ? x : 1LL * (mod - mod / x) * Inv(mod % x) % mod;}Tree S , T;TreeMatcher matcher;int main() {auto Input = [&](Tree &tree) {int n ;scanf("%d" , &n);tree.resize(n);for(int i = 1 , x , y ; i < n ; ++i) {scanf("%d %d" , &x , &y);tree.AddEdge(x - 1, y - 1);}7 行未改动