happyguy89

CF Div2A

Jul 21st, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int t;
  6.     cin>>t;
  7.     while(t--)
  8.     {
  9.         int n,m;
  10.         int s1[n+5];
  11.         int s2[m+5];
  12.         int a=0;
  13.         cin>>n>>m;
  14.         for(int i=0;i<n;i++)
  15.         {
  16.             cin>>s1[i];
  17.         }
  18.         for(int j=0;j<m;j++)
  19.         {
  20.             cin>>s2[j];
  21.         }
  22.         for(int i=0;i<n;i++)
  23.         {
  24.             for(int j=0;j<m;j++)
  25.             {
  26.                 if(s2[j]==s1[i])
  27.                 {
  28.  
  29.                     a=s1[i];
  30.                     break;
  31.  
  32.                 }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.             }
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.         }
  46.         if(a!=0)
  47.         {
  48.             cout<<"YES"<<endl;
  49.             cout<<"1"<<" "<<a<<endl;
  50.         }
  51.         else
  52.         {
  53.             cout<<"NO"<<endl;
  54.         }
  55.  
  56.  
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment