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 11:53:48
Task:Grid
Sender:Game of Nolife
Submission time:2017-05-27 11:53:48
Status:READY
Result:ACCEPTED

Show test data

Code

#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

const int S=3000;

bitset<S> lol[S];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i=0;i<n;i++){
		string s;
		cin>>s;
		for (int j=0;j<m;j++){
			if (s[j]=='1') lol[i][j]=1;
		}
	}
	ll ans=0;
	for (int i=0;i<n;i++){
		for (int ii=i+1;ii<n;ii++){
			ll t=(lol[i]&lol[ii]).count();
			ans+=t*(t-1)/2;
		}
	}
	cout<<ans<<endl;
}