27492023-01-20 18:56:57CattVarázserdőcpp17Wrong answer 50/1002.164s387328 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

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;
        mo %= MOD;
        v[x][z] += v[y][z-1] + 1;
        v[y][z] += v[x][z-1] + 1;
    }

    cout << (mo + MOD - m) % MOD;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1816 KiB
2Accepted2ms2052 KiB
3Accepted2ms2128 KiB
subtask27/7
4Accepted2ms2288 KiB
5Accepted3ms2976 KiB
6Accepted16ms7816 KiB
7Accepted17ms8884 KiB
8Accepted1.192s316484 KiB
9Accepted1.11s298736 KiB
10Accepted920ms280308 KiB
11Accepted856ms267208 KiB
12Accepted837ms261616 KiB
13Accepted822ms261176 KiB
subtask39/9
14Accepted2ms3652 KiB
15Accepted3ms3976 KiB
16Accepted156ms48124 KiB
17Accepted739ms85296 KiB
18Accepted1.746s305956 KiB
19Accepted1.371s233120 KiB
20Accepted1.222s240080 KiB
subtask414/14
21Accepted2ms4020 KiB
22Accepted2ms4132 KiB
23Accepted2ms4024 KiB
24Accepted2ms4020 KiB
subtask520/20
25Accepted4ms4576 KiB
26Accepted8ms6196 KiB
27Accepted8ms5384 KiB
28Accepted9ms6364 KiB
29Accepted8ms6516 KiB
30Accepted8ms6332 KiB
31Accepted8ms5692 KiB
32Accepted8ms5872 KiB
subtask60/50
33Accepted17ms10448 KiB
34Accepted206ms65448 KiB
35Accepted1.065s65948 KiB
36Wrong answer1.128s70364 KiB
37Wrong answer1.787s314152 KiB
38Wrong answer1.72s348512 KiB
39Accepted2.164s387328 KiB
40Accepted1.672s355920 KiB
41Accepted1.672s155956 KiB