#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=5005;
int n,m,ans;
vector<int> g[N];
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;
//g[u].emplace_back(v);
}
for(int u=1;u<=n;u++){
for(int v=1;v<=u;v++) out[u][v]=0;
for(int v=u+1;v<=n;v++) if(out[u][v]) 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 |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
462 ms |
3520 KB |
Output is correct |
17 |
Correct |
447 ms |
4440 KB |
Output is correct |
18 |
Correct |
477 ms |
4400 KB |
Output is correct |
19 |
Correct |
461 ms |
4424 KB |
Output is correct |
20 |
Correct |
573 ms |
4440 KB |
Output is correct |
21 |
Correct |
442 ms |
3560 KB |
Output is correct |
22 |
Correct |
446 ms |
4452 KB |
Output is correct |
23 |
Correct |
539 ms |
4440 KB |
Output is correct |
24 |
Correct |
528 ms |
4400 KB |
Output is correct |
25 |
Correct |
519 ms |
4436 KB |
Output is correct |
26 |
Correct |
522 ms |
4440 KB |
Output is correct |
27 |
Correct |
492 ms |
3556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
724 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
468 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
1 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
462 ms |
3520 KB |
Output is correct |
17 |
Correct |
447 ms |
4440 KB |
Output is correct |
18 |
Correct |
477 ms |
4400 KB |
Output is correct |
19 |
Correct |
461 ms |
4424 KB |
Output is correct |
20 |
Correct |
573 ms |
4440 KB |
Output is correct |
21 |
Correct |
442 ms |
3560 KB |
Output is correct |
22 |
Correct |
446 ms |
4452 KB |
Output is correct |
23 |
Correct |
539 ms |
4440 KB |
Output is correct |
24 |
Correct |
528 ms |
4400 KB |
Output is correct |
25 |
Correct |
519 ms |
4436 KB |
Output is correct |
26 |
Correct |
522 ms |
4440 KB |
Output is correct |
27 |
Correct |
492 ms |
3556 KB |
Output is correct |
28 |
Runtime error |
2 ms |
724 KB |
Execution killed with signal 11 |
29 |
Halted |
0 ms |
0 KB |
- |