10634 | 2024-04-07 14:57:11 | 111 | Varázserdő | cpp17 | Wrong answer 14/100 | 4ms | 3980 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,M;
cin>>N>>M;
if(N>1000||M>5000)exit(1);
vector<tuple<int,int,int>>e(M);
for(int i=0;i<M;i++){
int a,b,c;
cin>>a>>b>>c;
e[i]={c,a,b};
}
sort(e.begin(),e.end());
int ans=0;
vector<int>v(N+1),w(N+1);
for(int i=0;i<M;i++){
auto[c,a,b]=e[i];
w[a]+=v[b]+1;
w[b]+=v[a]+1;
int cc=i+1==M?MOD:get<0>(e[i+1]);
if(c!=cc){
for(int i=1;i<=N;i++){
if(c+1==cc){
v[i]=w[i];
}
ans+=w[i];
w[i]=0;
}
}
}
ans-=M;
cout<<ans<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2024 KiB | ||||
3 | Accepted | 3ms | 2252 KiB | ||||
subtask2 | 0/7 | ||||||
4 | Wrong answer | 3ms | 2472 KiB | ||||
5 | Accepted | 3ms | 2600 KiB | ||||
6 | Runtime error | 3ms | 2684 KiB | ||||
7 | Runtime error | 2ms | 2788 KiB | ||||
8 | Runtime error | 2ms | 2800 KiB | ||||
9 | Runtime error | 2ms | 2820 KiB | ||||
10 | Runtime error | 3ms | 2960 KiB | ||||
11 | Runtime error | 2ms | 3064 KiB | ||||
12 | Runtime error | 2ms | 3076 KiB | ||||
13 | Runtime error | 2ms | 3092 KiB | ||||
subtask3 | 0/9 | ||||||
14 | Accepted | 2ms | 3108 KiB | ||||
15 | Accepted | 3ms | 3248 KiB | ||||
16 | Runtime error | 2ms | 3300 KiB | ||||
17 | Runtime error | 2ms | 3312 KiB | ||||
18 | Runtime error | 3ms | 3348 KiB | ||||
19 | Runtime error | 2ms | 3432 KiB | ||||
20 | Runtime error | 2ms | 3432 KiB | ||||
subtask4 | 14/14 | ||||||
21 | Accepted | 2ms | 3516 KiB | ||||
22 | Accepted | 2ms | 3428 KiB | ||||
23 | Accepted | 3ms | 3572 KiB | ||||
24 | Accepted | 2ms | 3656 KiB | ||||
subtask5 | 0/20 | ||||||
25 | Accepted | 3ms | 3588 KiB | ||||
26 | Accepted | 4ms | 3884 KiB | ||||
27 | Accepted | 4ms | 3888 KiB | ||||
28 | Accepted | 4ms | 3884 KiB | ||||
29 | Accepted | 4ms | 3888 KiB | ||||
30 | Accepted | 4ms | 3880 KiB | ||||
31 | Wrong answer | 4ms | 3980 KiB | ||||
32 | Wrong answer | 4ms | 3980 KiB | ||||
subtask6 | 0/50 | ||||||
33 | Runtime error | 2ms | 3628 KiB | ||||
34 | Runtime error | 2ms | 3628 KiB | ||||
35 | Runtime error | 2ms | 3736 KiB | ||||
36 | Runtime error | 2ms | 3836 KiB | ||||
37 | Runtime error | 2ms | 3736 KiB | ||||
38 | Runtime error | 2ms | 3740 KiB | ||||
39 | Runtime error | 2ms | 3744 KiB | ||||
40 | Runtime error | 2ms | 3648 KiB | ||||
41 | Runtime error | 2ms | 3648 KiB |