摘要:
A:bfs+优先队列。。。。第一天只能感染defence小于等于1的并且与之连接的机器,第二天只能感染defence小于等于2的并且与之连接的机器.。。。。。依次往后推。View Code #include <cstdio>#include <cstring>#include <iostream>#include <queue>#define maxn 505using namespace std;int g[maxn][maxn],ct[maxn*maxn];int dir[4][2] = {{0,1},{0,-1},{1,0},{-1,0}} 阅读全文
摘要:
http://poj.org/problem?id=3253View Code #include #include #include #include #define maxn 20007using namespace std;struct cmp{ bool operator() (int &a,int &b) { return a > b; }};int main(){ priority_queue,cmp>q; int n,i,sum,a; while (~scanf("%d",&n)) { while (!q.empty()... 阅读全文
摘要:
http://poj.org/problem?id=2503很简单的一个哈希,本来想求和然后模一个数哈希呢,提交果断tle。。。郁闷。最后看了看别人的哈希,在处理的时候好像用到了经典的unix的ELF哈希函数给输入字符串生产哈希值.我直接套的这个函数,提交就A了。。。unix的ELF哈希函数View Code unsigned int ELFHash(char* str){ unsigned int hash = 0; unsigned int x = 0; while (*str){ hash = (hash << 4) + (*str++); ... 阅读全文