This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool adj[50][50];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
for(int i=1;i<=m;i++){
int a,b;cin>>a>>b;
adj[a][b] = true;
int ans = 0;
for(int x=1;x<=n;x++){
for(int y=1;y<=n;y++){
for(int z=1;z<=n;z++){
if(z==x)continue;
if(adj[x][y] and adj[y][z] and adj[z][y])adj[x][z]=true;
}
}
}
for(auto&x:adj)for(bool&y:x)if(y)ans++;
cout << ans << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |