Advertisement
Guest User

P_sistem

a guest
Jul 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4. using namespace std;
  5. char c[100][100];
  6. struct {int a;
  7. char b;}A[28];
  8.  
  9. int p_sistem(int m,int p, int n)
  10. {
  11.     int i,j,h,x;
  12.     for(i=0;i<n;i++)
  13.         {cin>>c[i];
  14.         if(strlen(c[i])!=p)
  15.             return 0;
  16.         for(j=0;j<strlen(c[i]);j++)
  17.             for(h=0;h<m;h++)
  18.                 if(A[h].b==c[i][j])
  19.                     A[h].a=1;
  20.         }
  21.     for(i=0;i<m;i++)
  22.         if(A[i].a==0)
  23.             return 0;
  24.     for(i=0;i<n;i++)
  25.         {for(j=i+1;i<=n;i++)
  26.             {
  27.                 x=0;
  28.                 for(h=0;h<p;h++)
  29.                 if(c[i][h]==c[j][h])
  30.                     x++;
  31.             }
  32.         if(x>1)
  33.             return 0;
  34.         }
  35.     return 1;
  36. }
  37.  
  38. int main()
  39. {
  40.     int n,p,m,i;
  41.     cin>> m;
  42.     for(i=0;i<m;i++)
  43.         A[i].b='a'+i;
  44.     cin>>n>>p;
  45.     if(p_sistem(m,p,n))
  46.        cout<<"DA";
  47.     else
  48.         cout<<"NU";
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement