2749 | 2023-01-20 18:56:57 | Catt | Varázserdő | cpp17 | Wrong answer 50/100 | 2.164s | 387328 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1816 KiB | ||||
2 | Accepted | 2ms | 2052 KiB | ||||
3 | Accepted | 2ms | 2128 KiB | ||||
subtask2 | 7/7 | ||||||
4 | Accepted | 2ms | 2288 KiB | ||||
5 | Accepted | 3ms | 2976 KiB | ||||
6 | Accepted | 16ms | 7816 KiB | ||||
7 | Accepted | 17ms | 8884 KiB | ||||
8 | Accepted | 1.192s | 316484 KiB | ||||
9 | Accepted | 1.11s | 298736 KiB | ||||
10 | Accepted | 920ms | 280308 KiB | ||||
11 | Accepted | 856ms | 267208 KiB | ||||
12 | Accepted | 837ms | 261616 KiB | ||||
13 | Accepted | 822ms | 261176 KiB | ||||
subtask3 | 9/9 | ||||||
14 | Accepted | 2ms | 3652 KiB | ||||
15 | Accepted | 3ms | 3976 KiB | ||||
16 | Accepted | 156ms | 48124 KiB | ||||
17 | Accepted | 739ms | 85296 KiB | ||||
18 | Accepted | 1.746s | 305956 KiB | ||||
19 | Accepted | 1.371s | 233120 KiB | ||||
20 | Accepted | 1.222s | 240080 KiB | ||||
subtask4 | 14/14 | ||||||
21 | Accepted | 2ms | 4020 KiB | ||||
22 | Accepted | 2ms | 4132 KiB | ||||
23 | Accepted | 2ms | 4024 KiB | ||||
24 | Accepted | 2ms | 4020 KiB | ||||
subtask5 | 20/20 | ||||||
25 | Accepted | 4ms | 4576 KiB | ||||
26 | Accepted | 8ms | 6196 KiB | ||||
27 | Accepted | 8ms | 5384 KiB | ||||
28 | Accepted | 9ms | 6364 KiB | ||||
29 | Accepted | 8ms | 6516 KiB | ||||
30 | Accepted | 8ms | 6332 KiB | ||||
31 | Accepted | 8ms | 5692 KiB | ||||
32 | Accepted | 8ms | 5872 KiB | ||||
subtask6 | 0/50 | ||||||
33 | Accepted | 17ms | 10448 KiB | ||||
34 | Accepted | 206ms | 65448 KiB | ||||
35 | Accepted | 1.065s | 65948 KiB | ||||
36 | Wrong answer | 1.128s | 70364 KiB | ||||
37 | Wrong answer | 1.787s | 314152 KiB | ||||
38 | Wrong answer | 1.72s | 348512 KiB | ||||
39 | Accepted | 2.164s | 387328 KiB | ||||
40 | Accepted | 1.672s | 355920 KiB | ||||
41 | Accepted | 1.672s | 155956 KiB |