#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];
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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
3 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 |
3 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 |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
3 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 |
3 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 |
1492 KB |
Output is correct |
16 |
Correct |
110 ms |
60384 KB |
Output is correct |
17 |
Correct |
113 ms |
60916 KB |
Output is correct |
18 |
Correct |
101 ms |
61432 KB |
Output is correct |
19 |
Correct |
99 ms |
61384 KB |
Output is correct |
20 |
Correct |
101 ms |
61404 KB |
Output is correct |
21 |
Correct |
83 ms |
61152 KB |
Output is correct |
22 |
Correct |
99 ms |
60544 KB |
Output is correct |
23 |
Correct |
129 ms |
60996 KB |
Output is correct |
24 |
Correct |
94 ms |
61480 KB |
Output is correct |
25 |
Correct |
95 ms |
61388 KB |
Output is correct |
26 |
Correct |
95 ms |
61488 KB |
Output is correct |
27 |
Correct |
81 ms |
61024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4069 ms |
783388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
3 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 |
3 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 |
1492 KB |
Output is correct |
16 |
Correct |
110 ms |
60384 KB |
Output is correct |
17 |
Correct |
113 ms |
60916 KB |
Output is correct |
18 |
Correct |
101 ms |
61432 KB |
Output is correct |
19 |
Correct |
99 ms |
61384 KB |
Output is correct |
20 |
Correct |
101 ms |
61404 KB |
Output is correct |
21 |
Correct |
83 ms |
61152 KB |
Output is correct |
22 |
Correct |
99 ms |
60544 KB |
Output is correct |
23 |
Correct |
129 ms |
60996 KB |
Output is correct |
24 |
Correct |
94 ms |
61480 KB |
Output is correct |
25 |
Correct |
95 ms |
61388 KB |
Output is correct |
26 |
Correct |
95 ms |
61488 KB |
Output is correct |
27 |
Correct |
81 ms |
61024 KB |
Output is correct |
28 |
Execution timed out |
4069 ms |
783388 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |