MAGCARI

FriendSet

Feb 25th, 2023
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. /*
  2.     Task    : _example
  3.     Author  : Phumipat C. [MAGCARI]
  4.     Language: C++
  5.     Created : 26 February 2023 [11:53]
  6. */
  7. #include<bits/stdc++.h>
  8. #define rep(i, a, b) for(int i = a; i <= (b); ++i)
  9. #define repr(i, a, b) for(int i = a; i >= (b); --i)
  10. #define repl(i, a, b) for(LL i = a; i <= (b); ++i)
  11. #define reprl(i, a, b) for(LL i = a; i >= (b); --i)
  12. #define all(x) begin(x),end(x)
  13. #define allst(x,y) (x).begin()+y,(x).end()
  14. #define rmdup(x) sort(all(x)),(x).resize(unique((x).begin(),(x).end())-(x).begin())
  15. #define sz(x) (int)(x).size()
  16. #define decp(x) fixed << setprecision(x)
  17. #define MOD (LL )(1e9+7)
  18. using namespace std;
  19. using LL = long long;
  20. using PII = pair<int ,int >;
  21. using PLL = pair<long long ,long long >;
  22. const int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
  23. const int dir8[2][8] = {{-1,-1,-1,0,1,1,1,0},{-1,0,1,1,-1,0,1,-1}};
  24. map<vector<int >,int > case1,case2;
  25. vector<int > friendList[100010];
  26. int main(){
  27.     cin.tie(0)->sync_with_stdio(0);
  28.     cin.exceptions(cin.failbit);
  29.     int n,m;
  30.     cin >> n >> m;
  31.     for(int i=1;i<=m;i++){
  32.         int x,y;
  33.         cin >> x >> y;
  34.         friendList[x].push_back(y);
  35.         friendList[y].push_back(x);
  36.     }
  37.     int ans = 0;
  38.     for(int i=1;i<=n;i++){
  39.         sort(friendList[i].begin(),friendList[i].end());
  40.         ans+=case1[friendList[i]];
  41.         case1[friendList[i]]++;
  42.  
  43.         friendList[i].push_back(i);
  44.         sort(friendList[i].begin(),friendList[i].end());
  45.         ans+=case2[friendList[i]];
  46.         case2[friendList[i]]++;
  47.     }
  48.     cout << ans << '\n';
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment