Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : _example
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 26 February 2023 [11:53]
- */
- #include<bits/stdc++.h>
- #define rep(i, a, b) for(int i = a; i <= (b); ++i)
- #define repr(i, a, b) for(int i = a; i >= (b); --i)
- #define repl(i, a, b) for(LL i = a; i <= (b); ++i)
- #define reprl(i, a, b) for(LL i = a; i >= (b); --i)
- #define all(x) begin(x),end(x)
- #define allst(x,y) (x).begin()+y,(x).end()
- #define rmdup(x) sort(all(x)),(x).resize(unique((x).begin(),(x).end())-(x).begin())
- #define sz(x) (int)(x).size()
- #define decp(x) fixed << setprecision(x)
- #define MOD (LL )(1e9+7)
- using namespace std;
- using LL = long long;
- using PII = pair<int ,int >;
- using PLL = pair<long long ,long long >;
- const int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
- const int dir8[2][8] = {{-1,-1,-1,0,1,1,1,0},{-1,0,1,1,-1,0,1,-1}};
- map<vector<int >,int > case1,case2;
- vector<int > friendList[100010];
- int main(){
- cin.tie(0)->sync_with_stdio(0);
- cin.exceptions(cin.failbit);
- int n,m;
- cin >> n >> m;
- for(int i=1;i<=m;i++){
- int x,y;
- cin >> x >> y;
- friendList[x].push_back(y);
- friendList[y].push_back(x);
- }
- int ans = 0;
- for(int i=1;i<=n;i++){
- sort(friendList[i].begin(),friendList[i].end());
- ans+=case1[friendList[i]];
- case1[friendList[i]]++;
- friendList[i].push_back(i);
- sort(friendList[i].begin(),friendList[i].end());
- ans+=case2[friendList[i]];
- case2[friendList[i]]++;
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment