이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
const ll INF = 1e18;
const ll MAXN = 50;
bool edge[MAXN][MAXN];
int main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);
ll n,m;
cin>>n>>m;
ll ans = 0;
for (ll j = 1;j <= m;j ++){
ll x,y;
cin>>x>>y;
if (edge[x][y] == 0){
edge[x][y] = 1;
ans++;
for (ll x = 1;x <= n;x ++){
for (ll y = 1;y <= n;y ++){
if (edge[x][y]){
for (ll z = 1;z <= n;z ++){
if (edge[y][z] && edge[z][y] && z != x){
if (!edge[x][z]){
edge[x][z] = 1;
ans++;
}
}
}
}
}
}
}
cout<<ans<<'\n';
}
// dnc(0,n,all);
// for (ll i = 1;i <= cnt;i ++)cout<<ans[i].fi<<' '<<ans[i].se<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |