Guest User

Untitled

a guest
Dec 11th, 2015
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <fstream>
  2. #include <vector>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. ifstream ifs("input.txt");
  8. ofstream ofs("output.txt");
  9.  
  10. inline bool f(int a,int b){
  11.     if(a==b)return 0;
  12.     if((a&b)==b)return 1;
  13.     if((a&b)==a)return 1;
  14.     return 0;
  15. }
  16. int main()
  17. {
  18.     int n,m;
  19.     ifs>>n>>m;
  20.     vector<int> v(n);
  21.     char ch;
  22.     int t,s=pow(2,m);;
  23.     for(int i=0;i<n;i++){
  24.         t=s;
  25.         for(int j=0;j<m;j++){
  26.             ifs>>ch;
  27.             v[i]+=t*((ch=='+')?1:0);
  28.             t/=2;
  29.             }
  30.         }
  31.     int ans=0;
  32.     for(int i=0;i<n-1;i++){
  33.         for(int j=i+1;j<n;j++)
  34.             ans+=f(v[i],v[j]);
  35.     }
  36.     ofs<<ans;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment