27482023-01-20 18:55:18CattVarázserdőcpp17Wrong answer 21/1002.161s387232 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll n,m;
    cin >> n >> m;

    vector<pair<ll, pair<ll, ll>> > g(m);
    for(ll i = 0; i < m; i++) {
        ll x,y,z;
        cin >> x >> y >> z;
        g[i] = {z, {x, y}};
    }

    vector<map<ll, ll> > v(n+1);
    ll mo = 0;

    sort(g.begin(), g.end());
    for(ll i = 0; i < m; i++) {
        ll x,y,z;
        z = g[i].first, x = g[i].second.first, y = g[i].second.second;
        mo += v[x][z-1] + v[y][z-1] + 2;
        v[x][z] += v[y][z-1] + 1;
        v[y][z] += v[x][z-1] + 1;
    }

    cout << mo - m;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted2ms2056 KiB
3Accepted2ms2136 KiB
subtask27/7
4Accepted2ms2292 KiB
5Accepted3ms2988 KiB
6Accepted14ms7764 KiB
7Accepted16ms8956 KiB
8Accepted1s316740 KiB
9Accepted952ms298624 KiB
10Accepted1.019s280300 KiB
11Accepted848ms267376 KiB
12Accepted824ms261728 KiB
13Accepted816ms261208 KiB
subtask30/9
14Accepted2ms3528 KiB
15Accepted3ms3864 KiB
16Accepted155ms48160 KiB
17Accepted736ms85348 KiB
18Accepted1.922s305956 KiB
19Wrong answer1.328s233116 KiB
20Wrong answer1.225s240212 KiB
subtask414/14
21Accepted2ms4220 KiB
22Accepted2ms4224 KiB
23Accepted2ms4220 KiB
24Accepted2ms4348 KiB
subtask50/20
25Accepted3ms4984 KiB
26Accepted8ms6532 KiB
27Accepted8ms5796 KiB
28Accepted9ms7024 KiB
29Accepted8ms6928 KiB
30Accepted8ms6816 KiB
31Wrong answer8ms5984 KiB
32Wrong answer8ms5984 KiB
subtask60/50
33Accepted17ms10560 KiB
34Accepted207ms65648 KiB
35Wrong answer1.08s66064 KiB
36Wrong answer1.121s70436 KiB
37Wrong answer1.59s314124 KiB
38Wrong answer1.983s348388 KiB
39Wrong answer2.161s387232 KiB
40Wrong answer1.687s355940 KiB
41Accepted1.542s156052 KiB