Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <vector>
- #include <algorithm>
- #include <iostream>
- #include <cassert>
- using namespace std;
- #define f first
- #define s second
- const int MAXN = 2e5 + 3;
- int ile[MAXN];
- vector<int> v[MAXN];
- void DFS(int x, int oj) {
- ile[x]++;
- for (auto it:v[x]) {
- if (it != oj)
- DFS(it, x);
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- int n, x, y;
- string ss;
- cin >> n;
- assert(n >= 1 && n <= 200000);
- for (int i = 1; i < n; i++) {
- cin >> x >> y;
- v[x].push_back(y);
- v[y].push_back(x);
- assert(x >= 1 && x <= n);
- assert(y >= 1 && y <= n);
- assert(x != y);
- }
- DFS(1, 0);
- for (int i = 1; i <= n; i++)
- assert(ile[i] == 1);
- int lng = 0;
- for (int i = 1; i <= n; i++) {
- cin >> ss;
- for (int j = 0; j < (int)(ss.size()); j++) {
- assert((int)(ss[j]) >= 'a' && (int)(ss[j]) <= 'z');
- lng++;
- }
- }
- assert(lng >= n && lng <= 1000000);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement