Advertisement
rotti321

Untitled

Apr 14th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. constexpr int maxn=101;
  5.  
  6. int comp(int a[maxn][maxn], int n,int A[],int k)
  7. {
  8.     for(int i=1;i<=n-1;i++)
  9.     {
  10.         for(int j=i+1;j<=n;j++)
  11.         {
  12.             if(A[i]==A[j] && a[i][j]==1)
  13.             {
  14. ///             cout<<i<<" "<<j;
  15.                 return 0;
  16.             }
  17.         }
  18.     }
  19.     return 1;
  20. }
  21. int main()
  22. {
  23.     ifstream f("bipartit.in");
  24.     ofstream g("bipartit.out");
  25.     int A[maxn]={},n,m,a[maxn][maxn]={},x,y,k;
  26.     f>>n>>m;
  27.     for(int i=1;i<=m;i++)
  28.     {
  29.         f>>x>>y;
  30.         if(x<maxn && y<maxn)
  31.         a[x][y]=a[y][x]=1;
  32.     }
  33.     f>>k;
  34.     for(int i=1;i<=k;i++)
  35.     {
  36.         f>>x;
  37.         A[x]=1;
  38.     }
  39.     int verif;
  40.  ///   verif=bipartit(a,n,A,k);
  41.     verif=comp(a,n,A,k);
  42. /*    for(int i=1;i<=n;i++)
  43.     {
  44.         if(d(a,n,i)==0)
  45.             verif=0;
  46.     }
  47.     */
  48.     if(verif==1) g<<"DA";
  49.     else
  50.         g<<"NU";
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement