#include<bits/stdc++.h>
/*
Created By Tornado2004
*/
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("wormsort.in","r",stdin );
#define outF freopen("wormsort.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;
#define ll long long
//#define int ll
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
const int N = 2e5 + 3 , K = 11 , M = N * 4 ;
const ll MOD = 998244353 , oo = 1e9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;
//37
// (a ^ b / c ) % mod = (a ^ b ) % MOD * (c ^ (mod - 2)) % mod
// m is prime --> (a ^ m) % m = a % m
vector<int> adj[N];
int mat[1001][1001];
int vis[N] , vid ;
ll ans ;
ll dfs(int u , ll d ){
vis[u] = vid ;
ll c = 1 ;
for(auto f : adj[u]){
if(vis[f] != vid){
c += dfs(f , d + 1);
}
}
ans += c - 1 ;
return c ;
}
int32_t main()
{ //inF;
//i bnF;outF;
fastio;
int n , m ;
cin >> n >> m ;
for(int i = 0 ; i < m ; i ++){
int a , b;
cin >>a >> b;
mat[a][b] = mat[b][a] = 1 ;
adj[a].push_back(b);
adj[b].push_back(a);
}
if(n < 3)cout << 0 ;
else {
for(int i = 1 ; i <= n ; i ++)
for(int j = 1 ; j <= n ; j ++){
if(mat[i][j]){
vid ++ ;
vis[i] = vid , vis[j] = vid ;
dfs(j , 1);
}
//debug(ans)
}
cout << ans ;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
10 ms |
9932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
8652 KB |
Output is correct |
2 |
Correct |
21 ms |
8652 KB |
Output is correct |
3 |
Correct |
24 ms |
8652 KB |
Output is correct |
4 |
Correct |
29 ms |
8888 KB |
Output is correct |
5 |
Correct |
23 ms |
8844 KB |
Output is correct |
6 |
Correct |
21 ms |
8740 KB |
Output is correct |
7 |
Correct |
24 ms |
8780 KB |
Output is correct |
8 |
Correct |
22 ms |
8780 KB |
Output is correct |
9 |
Correct |
33 ms |
8752 KB |
Output is correct |
10 |
Correct |
17 ms |
8656 KB |
Output is correct |
11 |
Correct |
20 ms |
8652 KB |
Output is correct |
12 |
Correct |
14 ms |
8652 KB |
Output is correct |
13 |
Correct |
8 ms |
8652 KB |
Output is correct |
14 |
Correct |
7 ms |
8524 KB |
Output is correct |
15 |
Correct |
8 ms |
8396 KB |
Output is correct |
16 |
Correct |
8 ms |
7756 KB |
Output is correct |
17 |
Correct |
13 ms |
8908 KB |
Output is correct |
18 |
Correct |
18 ms |
8700 KB |
Output is correct |
19 |
Correct |
21 ms |
8780 KB |
Output is correct |
20 |
Correct |
18 ms |
8268 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
13 ms |
9932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
8652 KB |
Output is correct |
2 |
Correct |
20 ms |
8780 KB |
Output is correct |
3 |
Incorrect |
26 ms |
8740 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
9932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |