# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
536320 | rainboy | 우호 조약 체결 (JOI14_friends) | C11 | 4 ms | 932 KiB |
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 <stdio.h>
#define N 100
char adj[N][N]; int n, cnt;
void solve(int i, int j) {
int k;
if (adj[i][j] != 1)
return;
adj[i][j] = -1, cnt++;
for (k = 0; k < n; k++)
if (k != i && k != j && adj[i][k]) {
if (!adj[j][k])
adj[j][k] = 1, solve(j, k);
if (!adj[k][j])
adj[k][j] = 1, solve(k, j);
}
}
int main() {
int m, i, j;
scanf("%d%d", &n, &m);
while (m--) {
scanf("%d%d", &i, &j), i--, j--;
adj[i][j] = 1;
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
solve(i, j);
printf("%d\n", cnt);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |