27472023-01-20 18:54:38CattVarázserdőcpp17Wrong answer 21/1001.858s291500 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

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

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

    sort(g.begin(), g.end());
    for(int i = 0; i < m; i++) {
        int 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
1Accepted3ms1804 KiB
2Accepted2ms2060 KiB
3Accepted2ms2264 KiB
subtask27/7
4Accepted2ms2352 KiB
5Accepted3ms2744 KiB
6Accepted16ms6328 KiB
7Accepted17ms6852 KiB
8Accepted990ms243776 KiB
9Accepted1.07s230428 KiB
10Accepted971ms216780 KiB
11Accepted830ms206752 KiB
12Accepted785ms202420 KiB
13Accepted783ms202160 KiB
subtask30/9
14Accepted2ms3156 KiB
15Accepted3ms3700 KiB
16Accepted162ms37836 KiB
17Accepted703ms61168 KiB
18Accepted1.858s230132 KiB
19Wrong answer1.217s175764 KiB
20Wrong answer1.294s181032 KiB
subtask414/14
21Accepted2ms3836 KiB
22Accepted2ms3968 KiB
23Accepted2ms4040 KiB
24Accepted2ms4152 KiB
subtask50/20
25Accepted3ms4396 KiB
26Accepted8ms5732 KiB
27Accepted8ms5288 KiB
28Accepted8ms5888 KiB
29Accepted8ms5864 KiB
30Accepted8ms5756 KiB
31Wrong answer8ms5420 KiB
32Wrong answer8ms5492 KiB
subtask60/50
33Accepted18ms9300 KiB
34Accepted193ms51376 KiB
35Wrong answer1.052s39192 KiB
36Wrong answer1.088s42424 KiB
37Wrong answer1.72s236888 KiB
38Wrong answer1.659s262388 KiB
39Wrong answer1.8s291500 KiB
40Wrong answer1.827s268088 KiB
41Accepted1.613s108532 KiB