#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,ans;
bitset<N> out[N];
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 u=1;u<=n;u++){
for(int v=1;v<=u;v++) out[u][v]=0;
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
1492 KB |
Output is correct |
4 |
Correct |
2 ms |
1492 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1492 KB |
Output is correct |
8 |
Correct |
2 ms |
1508 KB |
Output is correct |
9 |
Correct |
2 ms |
1620 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 |
2 ms |
1492 KB |
Output is correct |
15 |
Correct |
2 ms |
1552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
1492 KB |
Output is correct |
4 |
Correct |
2 ms |
1492 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1492 KB |
Output is correct |
8 |
Correct |
2 ms |
1508 KB |
Output is correct |
9 |
Correct |
2 ms |
1620 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 |
2 ms |
1492 KB |
Output is correct |
15 |
Correct |
2 ms |
1552 KB |
Output is correct |
16 |
Correct |
99 ms |
60372 KB |
Output is correct |
17 |
Correct |
115 ms |
60936 KB |
Output is correct |
18 |
Correct |
104 ms |
61420 KB |
Output is correct |
19 |
Correct |
109 ms |
61524 KB |
Output is correct |
20 |
Correct |
96 ms |
61376 KB |
Output is correct |
21 |
Correct |
93 ms |
61124 KB |
Output is correct |
22 |
Correct |
104 ms |
60504 KB |
Output is correct |
23 |
Correct |
95 ms |
61020 KB |
Output is correct |
24 |
Correct |
96 ms |
61504 KB |
Output is correct |
25 |
Correct |
99 ms |
61384 KB |
Output is correct |
26 |
Correct |
96 ms |
61424 KB |
Output is correct |
27 |
Correct |
92 ms |
60940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4061 ms |
796744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
1492 KB |
Output is correct |
4 |
Correct |
2 ms |
1492 KB |
Output is correct |
5 |
Correct |
2 ms |
1492 KB |
Output is correct |
6 |
Correct |
2 ms |
1492 KB |
Output is correct |
7 |
Correct |
2 ms |
1492 KB |
Output is correct |
8 |
Correct |
2 ms |
1508 KB |
Output is correct |
9 |
Correct |
2 ms |
1620 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 |
2 ms |
1492 KB |
Output is correct |
15 |
Correct |
2 ms |
1552 KB |
Output is correct |
16 |
Correct |
99 ms |
60372 KB |
Output is correct |
17 |
Correct |
115 ms |
60936 KB |
Output is correct |
18 |
Correct |
104 ms |
61420 KB |
Output is correct |
19 |
Correct |
109 ms |
61524 KB |
Output is correct |
20 |
Correct |
96 ms |
61376 KB |
Output is correct |
21 |
Correct |
93 ms |
61124 KB |
Output is correct |
22 |
Correct |
104 ms |
60504 KB |
Output is correct |
23 |
Correct |
95 ms |
61020 KB |
Output is correct |
24 |
Correct |
96 ms |
61504 KB |
Output is correct |
25 |
Correct |
99 ms |
61384 KB |
Output is correct |
26 |
Correct |
96 ms |
61424 KB |
Output is correct |
27 |
Correct |
92 ms |
60940 KB |
Output is correct |
28 |
Execution timed out |
4061 ms |
796744 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |