#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int m,n;
vector<vector<int>> space;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> m >> n;
for(int i=0; i<m; i++) {
//한줄씩 입력
vector<int> row(n),tmp(n);
for(int j=0; j<n; j++) {
cin >> row[j];
tmp[j]=row[j];
}
//정렬(좌표압축하려고)
sort(tmp.begin(),tmp.end());
tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
//좌표 압축됨
vector<int> new_space(n);
for(int k=0; k<n; k++) {
int x = lower_bound(tmp.begin(),tmp.end(),row[k])-tmp.begin();
new_space.push_back(x);
}
space.push_back(new_space);
}
int cnt=0;
for(int i=0; i<m; i++) {
for(int j=i+1; j<m; j++) {
if(space[i]==space[j]) cnt++;
}
}
cout<< cnt;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: