Skip to content

Commit 75202d5

Browse files
committed
Create 18869_멀티버스 2.cpp
1 parent 2df9830 commit 75202d5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <bits/stdc++.h>
2+
#define FIO ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
3+
using namespace std;
4+
int N, M, x, ans;
5+
map<string,int>res;
6+
int main() {
7+
FIO;
8+
cin>>N>>M;
9+
//멀티버스
10+
for(int i=0;i<N;i++){
11+
map<int,int>m;
12+
vector<int>v,sort_v;
13+
//행성
14+
for(int j=0;j<M;j++){
15+
cin>>x;
16+
v.push_back(x);
17+
sort_v.push_back(x);
18+
}
19+
sort(sort_v.begin(),sort_v.end());
20+
21+
for(int j=0;j<M;j++) m[sort_v[j]]=j;
22+
23+
//압축 압축-value
24+
string str;
25+
for(auto it: v) str+= to_string(m[it]);
26+
27+
res[str] += 1;
28+
}
29+
//쌍 갯수
30+
for(auto it: res) ans+=(it.second*(it.second-1))/2;
31+
cout<<ans;
32+
return 0;
33+
}

0 commit comments

Comments
 (0)