#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e9+7;
const int N=1e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;
int n,m,ans,tmp;
vector<int> v[1005];
bool vis[1005];
int sz[1005];
void clr() {
for (int j=1;j<=n;j++) {
vis[j]=false;
sz[j]=0;
}
return;
}
void dfs(int i,int pp,int lvl) {
vis[i]=true;
sz[i]=1;
for (int j:v[i]) {
if (!vis[j]) {
dfs(j,i,lvl+1); sz[i]+=sz[j];
}
}
if (lvl>1) {
//cout<<i<<' '<<sz[i]<<' '<<pp<<' '<<tmp<<endl;
ans+=sz[i];
}
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(".in", "r", stdin); freopen(".out", "w", stdout);
cin>>n>>m;
for (int i=0;i<m;i++) {
int a,b; cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for (int i=1;i<=n;i++) {
clr();
tmp=i;
dfs(i,-1,0);
//cout<<i<<' '<<ans<<": "; for (int j=1;j<=n;j++) cout<<sz[j]<<' '; cout<<endl;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
340 KB |
Output is correct |
2 |
Correct |
13 ms |
392 KB |
Output is correct |
3 |
Correct |
13 ms |
340 KB |
Output is correct |
4 |
Correct |
19 ms |
340 KB |
Output is correct |
5 |
Correct |
16 ms |
340 KB |
Output is correct |
6 |
Correct |
16 ms |
340 KB |
Output is correct |
7 |
Correct |
18 ms |
352 KB |
Output is correct |
8 |
Correct |
16 ms |
432 KB |
Output is correct |
9 |
Correct |
15 ms |
340 KB |
Output is correct |
10 |
Correct |
11 ms |
468 KB |
Output is correct |
11 |
Correct |
10 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
340 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
10 ms |
340 KB |
Output is correct |
18 |
Correct |
10 ms |
340 KB |
Output is correct |
19 |
Correct |
8 ms |
340 KB |
Output is correct |
20 |
Correct |
9 ms |
400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
384 KB |
Output is correct |
2 |
Correct |
14 ms |
388 KB |
Output is correct |
3 |
Incorrect |
15 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |