daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Nov 21st, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int ap[10001];
  6. int a[1001][1001];
  7.  
  8. int main()
  9. { int n,m,j,i;
  10.  long long maxim;
  11.  maxim=0;
  12.  
  13.     cin>>n>>m;
  14.  
  15.     for( i = 1; i <= n ; ++i)
  16.          for ( j = 1 ; j <= m ; ++j) {cin>>a[i][j];
  17.                                         if(a[i][j]>maxim) maxim=a[i][j];}
  18.  
  19. for( j = 1 ; j <= m ; ++ j ) {ap[a[1][j]]++;
  20.                             ap[a[n][j]]++;}
  21.  
  22.   for( i = 1 ; i <= n ; ++i) {ap[a[i][1]]++;
  23.                             ap[a[i][m]]++;
  24.  
  25.  
  26.   }
  27.  
  28.   for( i =1 ; i <=maxim ; ++i) if(ap[i]>0) cout<<i<<" ";
  29.  
  30.   return 0;
  31.  
  32. }
RAW Paste Data
Top