Advertisement
NgJaBach

Cow Gymnastics

Jan 23rd, 2023 (edited)
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. // NgJaBach: Forever Meadow <3
  2.  
  3. #include<bits/stdc++.h>
  4.  
  5. using namespace std;
  6. typedef long long int ll;
  7. typedef unsigned long long ull;
  8. #define pb push_back
  9. #define pob pop_back
  10. #define mp make_pair
  11. #define upb upper_bound
  12. #define lwb lower_bound
  13. #define bend(a) a.begin(),a.end()
  14. #define rev(x) reverse(bend(x))
  15. #define mset(a) memset(a, 0, sizeof(a))
  16. #define fi first
  17. #define se second
  18. #define gcd __gcd
  19. #define getl(s) getline(cin, s);
  20. #define setpre(x) fixed << setprecision(x)
  21. #define endl '\n'
  22. const int N=200050,M=1000000007;
  23. const ll INF=1e18+7;
  24. int main(){
  25.     ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
  26.     freopen("gymnastics.in","r",stdin);
  27.     freopen("gymnastics.out","w",stdout);
  28.     int n,m,cows[25][25],a,ans=0;
  29.     bool ok;
  30.     cin>>n>>m;
  31.     for(int i=0;i<n;++i){
  32.         for(int j=0;j<m;++j){
  33.             cin>>a;
  34.             cows[i][a]=j;
  35.         }
  36.     }
  37.     for(int i=1;i<=m;++i){
  38.         for(int j=1;j<=m;++j){
  39.             if(i==j) continue;
  40.             ok=true;
  41.             for(int k=0;k<n;++k){
  42.                 if(cows[k][i]<=cows[k][j]){
  43.                     ok=false;
  44.                     break;
  45.                 }
  46.             }
  47.             if(ok) ++ans;
  48.         }
  49.     }
  50.     cout<<ans;
  51.     return 0;
  52. }
  53. /*
  54. ==================================+
  55. INPUT:                            |
  56. ------------------------------    |
  57.  
  58. ------------------------------    |
  59. ==================================+
  60. OUTPUT:                           |
  61. ------------------------------    |
  62.  
  63. ------------------------------    |
  64. ==================================+
  65. */
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement