记录编号 |
575820 |
评测结果 |
AAAAAAAAAAA |
题目名称 |
中心台站建设 |
最终得分 |
100 |
用户昵称 |
惠惠 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.016 s |
提交时间 |
2022-09-28 20:11:26 |
内存使用 |
1.81 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n, now[110] = {0}, b = 1, now_plan[110], plan[10010][110], ans = 200;
bool t[110][110] = {0};
void go(int need, int now_s)
{
if(need > ans) return;
now_plan[need] = now_s;
for(int i = 1; i <= n; ++i)
{
if(t[now_s][i] == 1) ++now[i];
}
bool done = true;
bool searched[110] = {0};
for(int i = 1; i <= n; ++i)
{
if(now[i] == 0)
{
done = false;
for(int j = now_s + 1; j <= n && !searched[j]; ++j)
{
if(t[j][i] == 1)
{
searched[j] = true;
go(need + 1, j);
}
}
}
}
if(done)
{
if(need < ans)
{
b = 1;
ans = need;
}
else ++b;
for(int i = 1; i <= need; ++i)
{
plan[b][i] = now_plan[i];
}
}
for(int i = 1; i <= n; ++i)
{
if(t[now_s][i] == 1) --now[i];
}
return;
}
int main()
{
freopen("zpj.in", "r", stdin);
freopen("zpj.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
{
scanf("%d", &t[i][j]);
}
t[i][i] = 1;
}
for(int i = 1; i <= n; ++i)
{
go(1, i);
}
printf("%d\n%d\n", ans, b);
for(int i = 1; i <= b; ++i)
{
for(int j = 1; j <= ans; ++j)
{
printf("%d ", plan[i][j]);
}
printf("\n");
}
return 0;
}