比赛 |
EYOI与SBOI开学欢乐赛7th |
评测结果 |
AAAAAAAAAAA |
题目名称 |
中心台站建设 |
最终得分 |
100 |
用户昵称 |
惠惠 |
运行时间 |
0.014 s |
代码语言 |
C++ |
内存使用 |
0.90 MiB |
提交时间 |
2022-09-23 20:50:28 |
显示代码纯文本
#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;
}