### Problem

A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the “receiving schools”). Note that if B is in the distribution list of school A, then A does not necessarily appear in the list of school B
You are to write a program that computes the minimal number of schools that must receive a copy of the new software in order for the software to reach all schools in the network according to the agreement (Subtask A). As a further task, we want to ensure that by sending the copy of new software to an arbitrary school, this software will reach all schools in the network. To achieve this goal we may have to extend the lists of receivers by new members. Compute the minimal number of extensions that have to be made so that whatever school we send the new software to, it will reach all other schools (Subtask B). One extension means introducing one new member into the list of receivers of one school.

### Code

```#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <iostream>
using namespace std;

const int maxn = 110;
int N, M;
vector<int> G[maxn];
int pre[maxn], lowlink[maxn], sccno[maxn], dfs_clock, scc_cnt;
int in[maxn], out[maxn];
stack<int> st;

void dfs(int u) {
st.push(u);
for(int i = 0; i < G[u].size(); ++i) {
int v = G[u][i];
if(!pre[v]) {
dfs(v);
} else if(!sccno[v]) {
}
}
++scc_cnt;
while(true) {
int x = st.top(); st.pop();
sccno[x] = scc_cnt;
if(x == u) break;
}
}
}

void find_scc() {
dfs_clock = scc_cnt = 0;
memset(sccno, 0, sizeof(sccno));
memset(pre, 0, sizeof(pre));
for(int i = 1; i <= N; ++i)
if(!pre[i]) dfs(i);
}

int main()
{
scanf("%d", &N);
for(int i = 1; i <= N; ++i) {
int to;
while(scanf("%d", &to), to)
G[i].push_back(to);
}
find_scc();
if(scc_cnt == 1) {
printf("1\n0\n");
return 0;
}
for(int i = 1; i <= N; ++i) {
for(int j = 0; j < G[i].size(); ++j) {
int u = i, v = G[i][j];
if(sccno[u] != sccno[v]) {
++in[sccno[v]];
++out[sccno[u]];
}
}
}
int cnt1 = 0, cnt2 = 0;
for(int i = 1; i <= scc_cnt; ++i) {
if(!in[i]) ++cnt1;
if(!out[i]) ++cnt2;
}
printf("%d\n%d\n", cnt1, max(cnt1, cnt2));
return 0;
}
```

PS: 地球离开了谁都会转，风走了，云不会纠缠。认真，就输了。