#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
using ll=long long;
using pii=array<int,2>;
using tii=array<int,3>;
const ll inf=1e18;
const int N=1e5+5;
int n,m;
ll ans;
bitset<N> out[N],clr;
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>m;
for(int u,v,i=1;i<=m;i++){
cin>>u>>v;
out[u][v]=1;
}
for(int i=1;i<=n;i++) clr[i]=1;
for(int u=1;u<=n;u++){
clr[u]=0;
out[u]&=clr;
if(out[u].count()){
int v=out[u]._Find_first();
out[v]|=out[u];
}
}
for(int i=1;i<=n;i++) ans+=out[i].count();
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
1560 KB |
Output is correct |
4 |
Correct |
3 ms |
1492 KB |
Output is correct |
5 |
Correct |
3 ms |
1512 KB |
Output is correct |
6 |
Correct |
3 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1492 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1492 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1492 KB |
Output is correct |
14 |
Correct |
3 ms |
1556 KB |
Output is correct |
15 |
Correct |
2 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
1560 KB |
Output is correct |
4 |
Correct |
3 ms |
1492 KB |
Output is correct |
5 |
Correct |
3 ms |
1512 KB |
Output is correct |
6 |
Correct |
3 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1492 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1492 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1492 KB |
Output is correct |
14 |
Correct |
3 ms |
1556 KB |
Output is correct |
15 |
Correct |
2 ms |
1492 KB |
Output is correct |
16 |
Correct |
81 ms |
61464 KB |
Output is correct |
17 |
Correct |
89 ms |
61492 KB |
Output is correct |
18 |
Correct |
93 ms |
61492 KB |
Output is correct |
19 |
Correct |
93 ms |
61392 KB |
Output is correct |
20 |
Correct |
89 ms |
61508 KB |
Output is correct |
21 |
Correct |
66 ms |
61528 KB |
Output is correct |
22 |
Correct |
82 ms |
61456 KB |
Output is correct |
23 |
Correct |
112 ms |
61492 KB |
Output is correct |
24 |
Correct |
87 ms |
61468 KB |
Output is correct |
25 |
Correct |
97 ms |
61448 KB |
Output is correct |
26 |
Correct |
84 ms |
61492 KB |
Output is correct |
27 |
Correct |
66 ms |
61492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
992 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
1560 KB |
Output is correct |
4 |
Correct |
3 ms |
1492 KB |
Output is correct |
5 |
Correct |
3 ms |
1512 KB |
Output is correct |
6 |
Correct |
3 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1492 KB |
Output is correct |
8 |
Correct |
2 ms |
1492 KB |
Output is correct |
9 |
Correct |
2 ms |
1492 KB |
Output is correct |
10 |
Correct |
2 ms |
1492 KB |
Output is correct |
11 |
Correct |
2 ms |
1492 KB |
Output is correct |
12 |
Correct |
2 ms |
1492 KB |
Output is correct |
13 |
Correct |
2 ms |
1492 KB |
Output is correct |
14 |
Correct |
3 ms |
1556 KB |
Output is correct |
15 |
Correct |
2 ms |
1492 KB |
Output is correct |
16 |
Correct |
81 ms |
61464 KB |
Output is correct |
17 |
Correct |
89 ms |
61492 KB |
Output is correct |
18 |
Correct |
93 ms |
61492 KB |
Output is correct |
19 |
Correct |
93 ms |
61392 KB |
Output is correct |
20 |
Correct |
89 ms |
61508 KB |
Output is correct |
21 |
Correct |
66 ms |
61528 KB |
Output is correct |
22 |
Correct |
82 ms |
61456 KB |
Output is correct |
23 |
Correct |
112 ms |
61492 KB |
Output is correct |
24 |
Correct |
87 ms |
61468 KB |
Output is correct |
25 |
Correct |
97 ms |
61448 KB |
Output is correct |
26 |
Correct |
84 ms |
61492 KB |
Output is correct |
27 |
Correct |
66 ms |
61492 KB |
Output is correct |
28 |
Runtime error |
992 ms |
1048576 KB |
Execution killed with signal 9 |
29 |
Halted |
0 ms |
0 KB |
- |