Advertisement
tiom4eg

H

Nov 13th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. // tiom4eg's precompiler options
  3. // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
  4. // IO settings
  5. #define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
  6. // Quick types
  7. #define ll long long
  8. #define ull unsigned long long
  9. #define pii pair <int, int>
  10. #define vi vector <int>
  11. #define mi vector <vector <int> >
  12. // Quick functions
  13. #define endl "\n"
  14. #define F first
  15. #define S second
  16. #define all(a) a.begin(), a.end()
  17. #define pb push_back
  18. #define fint(n) int n; cin >> n
  19. #define fstr(s) string s; cin >> s
  20. #define farr(a, n) int a[n]; for (int pog = 0; pog < n; ++pog) cin >> a[pog]
  21. // Quick fors
  22. #define FOR1(s, n) for (int i = s; i < n; ++i)
  23. #define FOR2(s, n) for (int j = s; j < n; ++j)
  24. #define FOR3(s, n) for (int k = s; k < n; ++k)
  25. #define RFOR(n, s) for (int l = n; l >= s; --l)
  26. // Pragmas
  27. #pragma GCC optimize("Ofast")
  28. // POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
  29. using namespace std;
  30.  
  31. ll n, m, res, h[1000000], g[2000000];
  32.  
  33. int main() {
  34.     cin >> n >> m;
  35.     h[0] = 1; g[n] = 1;
  36.     FOR1(1, n) {
  37.         h[i] = h[i - 1] * 1000000007;
  38.         g[i + n] = h[i];
  39.     }
  40.     FOR1(0, m) {
  41.         int a, b; cin >> a >> b;
  42.         g[a - 1] += h[b - 1];
  43.         g[a - 1 + n] += h[b - 1];
  44.         g[b - 1] += h[a - 1];
  45.         g[b - 1 + n] += h[a - 1];
  46.     }
  47.     sort(g, g + 2 * n);
  48.     for (ll i = 0; i < 2 * n;) {
  49.         ll j = i;
  50.         while (g[j] == g[i]) i++;
  51.         res += (i - j) * (i - j - 1) / 2;
  52.     }
  53.     cout << res;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement