fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. cin.tie(0);
  6. ios::sync_with_stdio(false);
  7.  
  8. int n, k;
  9. cin >> n >> k;
  10.  
  11. vector <vector <int>> g(n);
  12. int a, b;
  13.  
  14. cin >> a;
  15.  
  16. while (a != 0) {
  17. cin >> b;
  18.  
  19. g[a - 1].push_back(b - 1);
  20.  
  21. cin >> a;
  22. }
  23.  
  24. if (g[k - 1].size() == n) {
  25. cout << "YES";
  26. } else {
  27. cout << "N0";
  28. }
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 5316KB
stdin
3 1
1 2
1 3
0
stdout
N0