Advertisement
malinaX

testowanie testów

Aug 23rd, 2020
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <cstdio>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <iostream>
  5. #include <cassert>
  6.  
  7. using namespace std;
  8.  
  9. #define f first
  10. #define s second
  11.  
  12. const int MAXN = 2e5 + 3;
  13.  
  14. int ile[MAXN];
  15. vector<int> v[MAXN];
  16.  
  17. void DFS(int x, int oj) {
  18.     ile[x]++;
  19.     for (auto it:v[x]) {
  20.         if (it != oj)
  21.             DFS(it, x);
  22.     }
  23. }
  24.  
  25. int main() {
  26.     ios_base::sync_with_stdio(false);
  27.     cin.tie(nullptr);
  28.     int n, x, y;
  29.     string ss;
  30.     cin >> n;
  31.     assert(n >= 1 && n <= 200000);
  32.     for (int i = 1; i < n; i++) {
  33.         cin >> x >> y;
  34.         v[x].push_back(y);
  35.         v[y].push_back(x);
  36.         assert(x >= 1 && x <= n);
  37.         assert(y >= 1 && y <= n);
  38.         assert(x != y);
  39.     }
  40.     DFS(1, 0);
  41.     for (int i = 1; i <= n; i++)
  42.         assert(ile[i] == 1);
  43.     int lng = 0;
  44.     for (int i = 1; i <= n; i++) {
  45.         cin >> ss;
  46.         for (int j = 0; j < (int)(ss.size()); j++) {
  47.             assert((int)(ss[j]) >= 'a' && (int)(ss[j]) <= 'z');
  48.             lng++;
  49.         }
  50.     }
  51.     assert(lng >= n && lng <= 1000000);
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement