#include <bits/stdc++.h>
using namespace std ;
const int MAX = 1e5 + 10 ;
int arr[MAX] ;
int n , m ;
set<int>adj[MAX] ;
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin>>n>>m ;
for(int i = 0 ; i < m ; ++i)
{
int x , y ;
cin>>x>>y ;
adj[x].insert(y) ;
for(int it = 0 ; it < n+5 ; ++it)
{
for(int i = 1 ; i <= n ; ++i)
{
for(auto &j : adj[i])
{
for(auto &k : adj[j])
{
if(adj[k].find(j) != adj[k].end() && i != k)
adj[i].insert(k) ;
}
}
}
}
int ans = 0 ;
for(int i = 1 ; i <= n ; ++i)
ans += adj[i].size() ;
cout<<ans<<"\n" ;
}
return 0 ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
19 ms |
4948 KB |
Output is correct |
6 |
Correct |
17 ms |
4948 KB |
Output is correct |
7 |
Execution timed out |
5022 ms |
5196 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
19 ms |
4948 KB |
Output is correct |
6 |
Correct |
17 ms |
4948 KB |
Output is correct |
7 |
Execution timed out |
5022 ms |
5196 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4948 KB |
Output is correct |
4 |
Correct |
2 ms |
4948 KB |
Output is correct |
5 |
Correct |
19 ms |
4948 KB |
Output is correct |
6 |
Correct |
17 ms |
4948 KB |
Output is correct |
7 |
Execution timed out |
5022 ms |
5196 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |