daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest Dec 18th, 2018 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # pragma GCC optimize("O3")
  2. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  3. #pragma GCC optimize("unroll-loops")
  4. # include <bits/stdc++.h>
  5. std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
  6. # define ll long long
  7. # define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
  8. # define rc(s) return cout << s,0
  9. # define rcg(s) cout << s;exit(0)
  10. # define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
  11. # define db(x) cerr << #x << " = " << x << '\n'
  12. # define pb push_back
  13. # define mp make_pair
  14. # define all(s) s.begin(),s.end()
  15. # define sz(x) (int)((x).size())
  16. //# define int ll
  17. using namespace std;
  18.  
  19. int n,x;
  20. vector<int>vec[50005];
  21. ll m[6];
  22.  
  23. inline int readChar();
  24. template <class T = int> inline T readInt();
  25. template <class T> inline void writeInt( T x, char end = 0 );
  26. inline void writeChar( int x );
  27. inline void writeWord( const char *s );
  28.      
  29. /** Read */
  30.      
  31. static const int buf_size = 4096;
  32.      
  33. inline int getChar() {
  34.     static char buf[buf_size];
  35.     static int len = 0, pos = 0;
  36.     if (pos == len) {
  37.         pos = 0, len = fread(buf, 1, buf_size, stdin);
  38.     }
  39.     if (pos == len) {
  40.         return -1;
  41.     }
  42.     return buf[pos++];
  43. }
  44.      
  45. inline int readChar() {
  46.     int c = getChar();
  47.     while (c <= 32) {
  48.         c = getChar();
  49.     }
  50.     return c;
  51. }
  52.      
  53. template <class T>
  54. inline T readInt() {
  55.     int s = 1, c = readChar();
  56.     T x = 0;
  57.     if (c == '-')
  58.         s = -1, c = getChar();
  59.     while ('0' <= c && c <= '9')
  60.         x = x * 10 + c - '0', c = getChar();
  61.     return s == 1 ? x : -x;
  62. }
  63.      
  64. /** Write */
  65.      
  66. static int write_pos = 0;
  67. static char write_buf[buf_size];
  68.      
  69. inline void writeChar( int x ) {
  70.     if (write_pos == buf_size)
  71.         fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
  72.     write_buf[write_pos++] = x;
  73. }
  74.      
  75. template <class T>
  76. inline void writeInt( T x, char end ) {
  77.     if (x < 0)
  78.         writeChar('-'), x = -x;
  79.      
  80.     char s[24];
  81.     int n = 0;
  82.     while (x || !n)
  83.         s[n++] = '0' + x % 10, x /= 10;
  84.     while (n--)
  85.         writeChar(s[n]);
  86.     if (end)
  87.         writeChar(end);
  88. }
  89.  
  90. inline bool eq(vector<int>a,vector<int>b)
  91. {
  92.     if(sz(a) != sz(b)) return 0;
  93.     for(int i = sz(a) - 1;i + 1;i--) if(a[i] != b[i]) return 0;
  94.     return 1;
  95. }
  96.  
  97.     vector<vector<int>>shaq;
  98.  
  99.  
  100. inline bool cmp(const vector<int>&a,const vector<int>&b)
  101. {
  102.     if(sz(a) != sz(b)) return sz(a) < sz(b);
  103.     for(int i = 0;i < sz(a);i++)
  104.     {
  105.         if(a[i] != b[i]) return a[i] < b[i];
  106.     }
  107.     return 0;
  108. }
  109.  
  110. int32_t main(){_
  111.     freopen("cowpatibility.in","r",stdin);
  112.     freopen("cowpatibility.out","w",stdout);
  113.     n = readInt();
  114.     for(int i = 1;i <= n;i++)
  115.     {
  116.         for(int k = 1;k <= 5;k++)
  117.         {
  118.             x = readInt();
  119.             vec[i].pb(x);
  120.         }
  121.         sort(vec[i].begin(),vec[i].end());
  122.     }
  123.     for(int mask = 1;mask < (1 << 5);mask++)
  124.     {
  125.         for(int i = 1;i <= n;i++){
  126.         vector<int>aux;
  127.         for(int j = 0;j < 5;j++)
  128.         {
  129.             if(mask & (1 << j))
  130.             {
  131.                 aux.pb(vec[i][j]);
  132.             }
  133.         }
  134.         shaq.pb(aux);
  135.         }
  136.     }
  137.     sort(shaq.begin(),shaq.end(),&cmp);
  138.     int i = 0;
  139.     while(i < sz(shaq))
  140.     {
  141.         int j = i;
  142.         while(j < sz(shaq) && eq(shaq[j],shaq[i])) j++;
  143.         m[sz(shaq[i])] += (1LL*(j - i) * (j - i - 1)) / 2LL;
  144.         i = j;
  145.     }
  146.     ll ans = 0;
  147.     for(int i = 1;i <= 5;i++) if(i % 2 == 1) ans += m[i]; else ans -= m[i];
  148.     rc((1LL*n*(n-1))/2LL - ans);
  149. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top