随笔分类 -  搜索

UVA 11218 - KTV
摘要:brute force暴力枚举即可,位运算hash判重#include<stdio.h> int n,ans; int a[100],b[100],c[100],d[100],s[100]; void init(){ for(int i=1;i<=n;i++){ d[i]=(1<<a[i])+(1<<b[i])+(1<<c[i]); } } int main(){ int i,tm1,tm2; int ca=0; while(scanf("%d",&n)!=EOF && n){ ans=-1; f 阅读全文

posted @ 2012-01-27 22:45 c语言源码 阅读(231) 评论(0) 推荐(0)

UVA 321 - The New Villa BFS+位运算
摘要:状态总数10*2^10=10240,hash判重即可注意点:在A房间不能关掉自己房间的灯(oh,my god,太伤了!)#include<stdio.h> #include<string.h> #include<queue> using namespace std; int r,d,s,sum; bool map[11][11],sw[11][11]; bool visit[11][1100]; int type[11][1100]; // move 1 on 2 off 3 int before[11][1100]; int beforestate[11] 阅读全文

posted @ 2012-01-27 22:43 c语言源码 阅读(324) 评论(0) 推荐(0)

导航