Code Submission Evaluation System Login

CSES - HIIT Open 2017

HIIT Open 2017

Contest start:2017-05-27 11:00:00
Contest end:2017-05-27 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard


History
2017-05-27 13:22:37
2017-05-27 13:14:17
2017-05-27 13:09:40
Task:Grid
Sender:Kanadan virallinen maajoukkue
Submission time:2017-05-27 13:22:37
Status:READY
Result:ACCEPTED

Show test data

Code

#include<iostream>
#include<queue>
#include<stack>
#include<bitset>

using namespace std;

bitset<3000> mem[3000];

///HOHOOOOOOO UUSI YRITYSSSS @____@


int main(){
    cin.sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        mem[i] = bitset<3000>(s);
        
    }
    
    long long ret = 0;


    for(int i=0; i<n; i++){
        for(int j=0; j<i; j++){
            long long tmp = (mem[i]&mem[j]).count();
            ret+=(tmp*(tmp-1))/2;
        }
    }
    
    cout<<ret<<endl;
    return 0;
}