给一个n,n条竖的路,n条水平的路
给你n*n个点,是路的交点,工人会按找给的点的顺序,到达该点。 一天走一个点
如果该点任一路被铺过沥青,离开。
如果该点横竖的路都没铺过沥青,把2条路都铺上
输出铺沥青时候的 天数
直接模拟就好。。。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;
int heng[51];
int shu[51];
struct node
{
int l,r;
};
node tm[51*51];
int main()
{
int n;
int i,j;
scanf("%d",&n);
int a,b;
for (i=1;i<=n*n;i++)
{
scanf("%d%d",&a,&b);
tm[i].l=a;
tm[i].r=b;
}
int line=0;
for (i=1;i<=n*n;i++)
{
a=tm[i].l;
b=tm[i].r;
if (!heng[a]&&!shu[b])
{
if (line) printf(" ");
printf("%d",i);
line=1;
heng[a]=shu[b]=1;
}
}
printf("\n");
return 0;
}