HDU4190 Distributing Ballot Boxes


HDU 4190 举行大选,N (1

HDU4096 Universal Question Answering System


其实是2010年上海赛区F题,现场读入数据就写了很久…交上去之后是个诡异的错误,现在忘了是啥错误了… 连边判断连通性即可。这个题比较坑人…输入数据就比较恶心,当时还不会sscanf。名词和动词可能一样,所以需要两个map来存,还可能直接问are cat cat?要输出Y… BFS和DFS时间差不多… http://acm.fudan.edu.cn 还有数据呢。 #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <map> //#include <assert.h> using namespace std;   const int N = 205;   map<string, int> nmap, vmap; int mapcount;   int getn(char* ch) { if (!nmap.count(ch)) nmap[ch] = mapcount++; return nmap[ch]; }   int getv(char* ch) { if (!vmap.count(ch)) [...]

HDU3687 National Day Parade


国庆游行,学生们本来排成n*n的队形,休息时他们仅左右移动,现在求在什么位置恢复n*n队形,使所有学生当前位置到目标位置的距离的和最短。 n

HDU3682 To Be an Dream Architect


题意:一个 n x n x n 的立方体,每次消除一行(平行于坐标轴),共消除 m 次,求共消除了多少 1 * 1 * 1 的小块。(1

HDU4119 Isabella’s Message


给定密文和密文中可能出现的单词,按题意输出原文。   #include <iostream> #include <cstdio> #include <cstring>   using namespace std;   int n; char map[55][55],temp[55][55],newmap[55][55],mask[55][55]; char word[5][2555]; char list[105][25]; char s[5][10100]; int ans[5][10100];   void rotate() { for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) newmap[j][n-i+1]=temp[i][j]; } void getword(int num) { int pos=0; for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) { if (newmap[i][j]==’*') word[num][pos++]=map[i][j]; } } [...]

HDU4112 Break the Chocolate


将N*M*K的巧克力分成1*1*1,用刀切可以同时切多块,用手掰每次只能将一块掰成两块。 思路:用刀切显然是log2(m)+log2(n)+log2(k)(每个都取上整),手掰的话,首先n-1次掰成n块,然后m-1次掰成m*n块,最后k-1次掰成m*n*k块,(n-1)+n*(m-1)+m*n*(k-1),整理得m*n*k-1。后来看到一种想法,每掰一块多一个,所以就是m*n*k-1次。   #include <iostream> #include <cstdio> #include <cmath> using namespace std;   int ans(int n, int m, int k) { return ceil(log(double(n))/log(2.0)) + ceil(log(double(m))/log(2.0)) + ceil(log(double(k))/log(2.0)); } int main() { int t; int n, m, k; cin >> t; for (int i = 1; i <= t; i++) { cin >> n >> m [...]

HDU4121 Xiangqi


只有四种棋子:将、车、马、炮,黑方只有一个将,现在被红方将,红方有2至7个棋子,判断黑方是否被将死。 考虑黑将的四个行动方向,判断每个位置是否被将死即可。 将:判断两个将之间是否有棋子 车:同上 马:八个方向,容易出错,详见代码 炮:将与炮之间是否只有一个棋子 //不考虑黑方飞将也能过,不知道到底该不该考虑。。 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct point { int x,y; }g[10], r[10], h[10], c[10]; //bg:black general int gcount, rcount, hcount, ccount; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1};   const int hx[] = [...]