#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 vis[N] , vid ;
ll ans ;
int a , b , c ;
int aa = 0 ;
int timer ;
void dfs(int u){
timer ++ ;
if(timer > 1e4)return ;
if(u == c){
if(vis[b] == vid) aa = 1 ;
return ;
}
for(auto f : adj[u]){
if(timer > 1e4)return ;
if(vis[f] != vid){
vis[f] = vid ;
if(timer > 1e4)return ;
dfs(f);
if(timer > 1e4)return ;
vis[f] = 0 ;
}
}
}
int32_t main()
{ //inF;
//inF;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 ++){
for(int cc = 1 ; cc <= n; cc ++){
a = i , b = j , c = cc ;
if(a == b || a == c || b == c)continue ;
vid ++ ;
vis[a] = vid ;
aa = 0 ;
timer = 0 ;
dfs(a);
ans += aa ;
// if(aa)cout << a << " " << b << " " << c << endl;
}
}
}
cout << ans ;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
8 ms |
4940 KB |
Output is correct |
9 |
Correct |
133 ms |
4992 KB |
Output is correct |
10 |
Correct |
159 ms |
4992 KB |
Output is correct |
11 |
Correct |
4 ms |
4940 KB |
Output is correct |
12 |
Correct |
4 ms |
4940 KB |
Output is correct |
13 |
Correct |
4 ms |
4928 KB |
Output is correct |
14 |
Correct |
4 ms |
4940 KB |
Output is correct |
15 |
Correct |
4 ms |
4940 KB |
Output is correct |
16 |
Correct |
5 ms |
4940 KB |
Output is correct |
17 |
Correct |
4 ms |
4940 KB |
Output is correct |
18 |
Correct |
4 ms |
4940 KB |
Output is correct |
19 |
Correct |
4 ms |
4940 KB |
Output is correct |
20 |
Correct |
4 ms |
4940 KB |
Output is correct |
21 |
Correct |
4 ms |
4940 KB |
Output is correct |
22 |
Correct |
4 ms |
4940 KB |
Output is correct |
23 |
Correct |
4 ms |
4940 KB |
Output is correct |
24 |
Correct |
4 ms |
5008 KB |
Output is correct |
25 |
Correct |
4 ms |
4940 KB |
Output is correct |
26 |
Correct |
5 ms |
4940 KB |
Output is correct |
27 |
Correct |
4 ms |
4940 KB |
Output is correct |
28 |
Correct |
4 ms |
4940 KB |
Output is correct |
29 |
Correct |
4 ms |
4940 KB |
Output is correct |
30 |
Correct |
4 ms |
4940 KB |
Output is correct |
31 |
Correct |
4 ms |
4940 KB |
Output is correct |
32 |
Correct |
4 ms |
4940 KB |
Output is correct |
33 |
Correct |
4 ms |
4940 KB |
Output is correct |
34 |
Correct |
5 ms |
4940 KB |
Output is correct |
35 |
Correct |
4 ms |
4940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
8 ms |
4940 KB |
Output is correct |
9 |
Correct |
133 ms |
4992 KB |
Output is correct |
10 |
Correct |
159 ms |
4992 KB |
Output is correct |
11 |
Correct |
4 ms |
4940 KB |
Output is correct |
12 |
Correct |
4 ms |
4940 KB |
Output is correct |
13 |
Correct |
4 ms |
4928 KB |
Output is correct |
14 |
Correct |
4 ms |
4940 KB |
Output is correct |
15 |
Correct |
4 ms |
4940 KB |
Output is correct |
16 |
Correct |
5 ms |
4940 KB |
Output is correct |
17 |
Correct |
4 ms |
4940 KB |
Output is correct |
18 |
Correct |
4 ms |
4940 KB |
Output is correct |
19 |
Correct |
4 ms |
4940 KB |
Output is correct |
20 |
Correct |
4 ms |
4940 KB |
Output is correct |
21 |
Correct |
4 ms |
4940 KB |
Output is correct |
22 |
Correct |
4 ms |
4940 KB |
Output is correct |
23 |
Correct |
4 ms |
4940 KB |
Output is correct |
24 |
Correct |
4 ms |
5008 KB |
Output is correct |
25 |
Correct |
4 ms |
4940 KB |
Output is correct |
26 |
Correct |
5 ms |
4940 KB |
Output is correct |
27 |
Correct |
4 ms |
4940 KB |
Output is correct |
28 |
Correct |
4 ms |
4940 KB |
Output is correct |
29 |
Correct |
4 ms |
4940 KB |
Output is correct |
30 |
Correct |
4 ms |
4940 KB |
Output is correct |
31 |
Correct |
4 ms |
4940 KB |
Output is correct |
32 |
Correct |
4 ms |
4940 KB |
Output is correct |
33 |
Correct |
4 ms |
4940 KB |
Output is correct |
34 |
Correct |
5 ms |
4940 KB |
Output is correct |
35 |
Correct |
4 ms |
4940 KB |
Output is correct |
36 |
Correct |
5 ms |
5016 KB |
Output is correct |
37 |
Correct |
6 ms |
4940 KB |
Output is correct |
38 |
Execution timed out |
1077 ms |
4940 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
8900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
4940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
8516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1096 ms |
4940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1095 ms |
8516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
8 ms |
4940 KB |
Output is correct |
9 |
Correct |
133 ms |
4992 KB |
Output is correct |
10 |
Correct |
159 ms |
4992 KB |
Output is correct |
11 |
Correct |
4 ms |
4940 KB |
Output is correct |
12 |
Correct |
4 ms |
4940 KB |
Output is correct |
13 |
Correct |
4 ms |
4928 KB |
Output is correct |
14 |
Correct |
4 ms |
4940 KB |
Output is correct |
15 |
Correct |
4 ms |
4940 KB |
Output is correct |
16 |
Correct |
5 ms |
4940 KB |
Output is correct |
17 |
Correct |
4 ms |
4940 KB |
Output is correct |
18 |
Correct |
4 ms |
4940 KB |
Output is correct |
19 |
Correct |
4 ms |
4940 KB |
Output is correct |
20 |
Correct |
4 ms |
4940 KB |
Output is correct |
21 |
Correct |
4 ms |
4940 KB |
Output is correct |
22 |
Correct |
4 ms |
4940 KB |
Output is correct |
23 |
Correct |
4 ms |
4940 KB |
Output is correct |
24 |
Correct |
4 ms |
5008 KB |
Output is correct |
25 |
Correct |
4 ms |
4940 KB |
Output is correct |
26 |
Correct |
5 ms |
4940 KB |
Output is correct |
27 |
Correct |
4 ms |
4940 KB |
Output is correct |
28 |
Correct |
4 ms |
4940 KB |
Output is correct |
29 |
Correct |
4 ms |
4940 KB |
Output is correct |
30 |
Correct |
4 ms |
4940 KB |
Output is correct |
31 |
Correct |
4 ms |
4940 KB |
Output is correct |
32 |
Correct |
4 ms |
4940 KB |
Output is correct |
33 |
Correct |
4 ms |
4940 KB |
Output is correct |
34 |
Correct |
5 ms |
4940 KB |
Output is correct |
35 |
Correct |
4 ms |
4940 KB |
Output is correct |
36 |
Correct |
5 ms |
5016 KB |
Output is correct |
37 |
Correct |
6 ms |
4940 KB |
Output is correct |
38 |
Execution timed out |
1077 ms |
4940 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
4940 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
8 ms |
4940 KB |
Output is correct |
9 |
Correct |
133 ms |
4992 KB |
Output is correct |
10 |
Correct |
159 ms |
4992 KB |
Output is correct |
11 |
Correct |
4 ms |
4940 KB |
Output is correct |
12 |
Correct |
4 ms |
4940 KB |
Output is correct |
13 |
Correct |
4 ms |
4928 KB |
Output is correct |
14 |
Correct |
4 ms |
4940 KB |
Output is correct |
15 |
Correct |
4 ms |
4940 KB |
Output is correct |
16 |
Correct |
5 ms |
4940 KB |
Output is correct |
17 |
Correct |
4 ms |
4940 KB |
Output is correct |
18 |
Correct |
4 ms |
4940 KB |
Output is correct |
19 |
Correct |
4 ms |
4940 KB |
Output is correct |
20 |
Correct |
4 ms |
4940 KB |
Output is correct |
21 |
Correct |
4 ms |
4940 KB |
Output is correct |
22 |
Correct |
4 ms |
4940 KB |
Output is correct |
23 |
Correct |
4 ms |
4940 KB |
Output is correct |
24 |
Correct |
4 ms |
5008 KB |
Output is correct |
25 |
Correct |
4 ms |
4940 KB |
Output is correct |
26 |
Correct |
5 ms |
4940 KB |
Output is correct |
27 |
Correct |
4 ms |
4940 KB |
Output is correct |
28 |
Correct |
4 ms |
4940 KB |
Output is correct |
29 |
Correct |
4 ms |
4940 KB |
Output is correct |
30 |
Correct |
4 ms |
4940 KB |
Output is correct |
31 |
Correct |
4 ms |
4940 KB |
Output is correct |
32 |
Correct |
4 ms |
4940 KB |
Output is correct |
33 |
Correct |
4 ms |
4940 KB |
Output is correct |
34 |
Correct |
5 ms |
4940 KB |
Output is correct |
35 |
Correct |
4 ms |
4940 KB |
Output is correct |
36 |
Correct |
5 ms |
5016 KB |
Output is correct |
37 |
Correct |
6 ms |
4940 KB |
Output is correct |
38 |
Execution timed out |
1077 ms |
4940 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |