Saleh127

CF 1382A.cpp

Jul 21st, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9.  
  10. test
  11. {
  12. ll a[10000],c[10000],d=0,e,f,i,j,k,l,n,m;
  13. cin>>n>>m;
  14. for(i=0; i<n; i++)
  15. {
  16. cin>>a[i];
  17. }
  18. for(i=0; i<m; i++)
  19. {
  20. cin>>c[i];
  21. }
  22. sort(a,a+n);
  23. sort(c,c+m);
  24. for(i=0; i<n; i++)
  25. {
  26. for(j=0; j<m; j++)
  27. {
  28. if(a[i]==c[j])
  29. {
  30. d=a[i];
  31. break;
  32. }
  33. }
  34. }
  35. if(d==0) cout<<"NO"<<endl;
  36. else cout<<"YES"<<endl<<1<<" "<<d<<endl;
  37. }
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment