이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mk make_pair
typedef long long ll;
const int N=50+7;
int a[N][N];
int main(){
ios:: sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n,q;
cin>>n;
cin>>q;
int ans=0;
while(q--){
int v,u;
cin>>v>>u;
if(a[v][u]==0)ans++;
a[v][u]=1;
int k=1;
while(k){
k=0;
for(int x=1;x<=n;x++){
for(int y=1;y<=n;y++){
for(int z=1;z<=n;z++){
if(a[x][y] && z!=x && a[x][z]==0 && a[y][z] && a[z][y]){
k=1;
a[x][z]=1;
ans++;
}
}
}
}
}
cout<<ans<<endl;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |