Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef string str;
- #define sqrt sqrtl
- #define F first
- #define S second
- #define endl '\n'
- #define all(vc666) vc666.begin(), vc666.end()
- #define allr(vc666) vc666.rbegin(), vc666.rend()
- #define int long long
- const ll INF = (ll)1e18 + 7;
- const ll MOD = (ll)1e9 + 7;
- const ll ONE = 1;
- const ll max_sz = 1e5 + 1, max_sz2 = 101;
- ld EPS = 1e-7;
- ld PI = 3.1415926535897932384;
- mt19937_64 gen(time(0));
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- cout.tie(NULL);
- int t = 1;
- while (t--) {
- int n, m, i, x, y, ans = 0;
- cin >> n >> m;
- vector<set<int> > g(n);
- set<pair<int, int> > keys;
- vector<pair<int, int> > a(n);
- for (i = 0; i < n; i++) {
- a[i].second = i;
- }
- for (i = 0; i < m; i++) {
- cin >> x >> y;
- x--;
- y--;
- a[x].first++;
- a[y].first++;
- g[x].insert(y);
- g[y].insert(x);
- }
- sort(all(a));
- vector<int> id(n);
- for (i = 0; i < n; i++) {
- id[a[i].second] = i;
- }
- vector<vector<int> > g2(n);
- for (i = 0; i < n; i++) {
- x = a[i].second;
- for (auto u : g[x]) {
- if (id[u] > i) {
- g2[x].push_back(u);
- }
- }
- }
- vector<int> cort(n);
- for (i = 0; i < n - 2; i++) {
- x = a[i].second;
- for (auto u : g2[x]) {
- cort[id[u]]++;
- }
- for (auto u : g2[x]) {
- for (auto u2 : g2[u]) {
- if (cort[id[u2]]) {
- ans++;
- }
- }
- }
- for (auto u : g2[x]) {
- cort[id[u]]--;
- }
- }
- cout << ans << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement