您的位置:首页 > 其它

近期总结

2010-09-02 15:45 106 查看
选拔赛要开始了,最近一直在刷题。DP居多,线段树其次,感觉这两方面的进步非常的大,假期的集训没有白费。

DP还是卡了几个题的,线段树的内容:火星地图和阿特兰迪斯都过了,自己感觉线段树的思想理解的更深刻了,继承统计的优化,在这个过程中,还学习到了扫描线离散化能内容,以后需要多做题巩固一下。网络流……不太能做下去,感觉现在建图上遇到了瓶颈,狂刷二分图的时候留下了一些功底,但是可惜的是对网络流的流量,费用上的灵活运用帮助不大,也可能是我自己不能灵活运用的原因。选拔赛希望有个好结果,之后又是一段时间的学习了,ACM可能要放下,呃,不想学习那些没用个课……毛概什么的无聊,老师……唉就不说了。

说一个解题报告。poj2724二分图,之前一直没读懂题,今天再来看看,是水题呀……

做完之后看了解题报告,发现一个非常好用的东西,求2个数的二进制表示法是否只差1位!

方法看代码吧

代码

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

class max_match
{
private:
const int static size = 1100;
vector<int> adj[size];
int nx, ym[size];
bool check[size];
int infect[size];
bool find_path(int x);
public:
bool init();
void slove();
} g;

bool max_match::find_path(int x)
{
int s = adj[x].size(), w;
for (int i = 0; i < s; i++)
{
w = adj[x][i];
if (!check[w])
{
check[w] = true;
if (ym[w] == -1 || find_path(ym[w]))
{
ym[w] = x;
return true;
}
}
}
return false;
}

bool max_match::init()
{
int n, m;
char str[size];
if (scanf("%d %d", &n, &m) != 2)
return false;
if (n == 0 && m == 0)
return false;
nx = 0;
memset(ym, -1, sizeof (ym));
memset(check, false, sizeof (check));
for (int i = 0; i < m; i++)
{
scanf("%s", str);
int res = 0, tmp = 0;
for (int j = 0; str[j]; j++)
{
res <<= 1;
tmp <<= 1;
if (str[j] == '*')
tmp = 1;
else
res += str[j] - '0';
}
check[res] = true;
check[res + tmp] = true;
}
for (int i = 0; i < (1 << n); i++)
if (check[i])
infect[nx++] = i;
for (int i = 0; i < nx; i++)
adj[i].clear();
for (int i = 0; i < nx; i++)
for (int j = 0; j < nx; j++)
{
if (i == j)
continue;
int tmp = infect[i] ^ infect[j];
if (tmp && ((tmp & (tmp - 1)) == 0))
adj[i].push_back(j);
}
return true;
}

void max_match::slove()
{
int res = 0;
for (int i = 0; i < nx; i++)
{
memset(check, false, sizeof (check));
if (find_path(i))
res++;
}
printf("%d\n", nx - res / 2);
}

int main()
{
while (g.init())
g.slove();
return 0;
}


接下来的工作,整理模板。准备选拔赛,刷几个网络流,再复习复习一些数据结构什么的,搜索就那样了吧,一个假期都没有做过什么像样的搜索,唉……70大神的搜索题至今没AC……,淡定吧
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: