摘要:注意dp内部条件判断/*最多硬币问题Sample Input#3203 5 7Output#6*/#include <cstdio>#include <cstring>#include <iostream>#include <vector>using namespace std;#define INF 1000000000const int maxn=105;int n;int S;int V[m
阅读全文
摘要:DAG上的动态规划一定要结合图来思考,要心中有图,或者在纸上画图,谨记!这样可以真正理解!求解状态转移方程的过程其实就是在填写一个表格!把表填好了,所有状态就填好了 d(i)定义为以i开始到0结束的最长/短路
阅读全文
摘要:矩形之间的"可嵌套"关系是一个典型的二元关系,二元关系可以用图来建模。如果矩形X可以嵌套在矩形Y里,我们就从X到Y连一条有向边。这个有向图是无环的,因为一个矩形无法直接或间接地嵌套在自己的内部。换句话说,它是一个DAG。这样,我们的任务便是求DAG上的最长路径。 可画图分析一下。 打印字典序最小的一
阅读全文
摘要:https://www.luogu.com.cn/problem/UVA816 朝向也包含在节点状态里 // UVa816 Abbott's Revenge // Rujia Liu #include<cstdio> #include<cstring> #include<vector> #inclu
阅读全文
摘要:****@ *@@*@ *@**@ @@@*@ @@**@ 标记后图像: 00001 02201 02001 22201 22001
阅读全文
摘要:Optimal Programs As you know, writing programs is often far from being easy. Things become even harder if your programs have to be as fast as possible. And sometimes there is reason for them to ...
阅读全文
摘要:找到最后处理的运算符,它是整个树的根,然后递归处理。 注意:下面代码不能处理 -1这样的表达式。 #include #include using namespace std;
const int MAXN = 1000;
int lch[MAXN],rch[MAXN]; //每个结点的左右儿子
char op[MAXN]; //存放每个结点的字符
char input[M...
阅读全文
摘要:还是畅通工程 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 25926 Accepted Submission(s): 11549 Problem Description 某省调查乡村交通状况,得到的统计表中列出了...
阅读全文
摘要:A Puzzling Problem The goal of this problem is to write a program which will take from 1 to 5 puzzle pieces such as those shown below and arrange them, if possible, to form a square. An example ...
阅读全文
摘要:Graph Coloring You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the graph and the only available colors are black and white. Th...
阅读全文
摘要:Firetruck The Center City fire department collaborates with the transportation department to maintain maps of the city which reflects the current status of the city streets. On any given day, se...
阅读全文
摘要:Transportation Ruratania is just entering capitalism and is establishing new enterprising activities in many fields including transport. The transportation company TransRuratania is starting ...
阅读全文
摘要:The Settlers of Catan Within Settlers of Catan, the 1995 German game of the year, players attempt to dominate an island by building roads, settlements and cities across its uncharted wilderness....
阅读全文
摘要:Mapping the Swaps Sorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in the well-known bubble sort. If we list the id...
阅读全文
摘要:Your task is to write a program that can decide whether you can find an arithmetic expression consisting of five given numbers (1 {1,2,3,4,5} is a bijective functionand {+,-,*} (1#include#include#inc...
阅读全文
摘要:Getting in Line Computer networking requires that the computers in the network be linked. This problem considers a ``linear" network in which the computers are chained together so that each is...
阅读全文
摘要:Bandwidth Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an ordering on the elements in V, then the bandwidth of a node v is defined as the maximum distance in ...
阅读全文
摘要:7.4.3困难的串 学习点:dfs加入返回值,递归搜索过程中如果有一个成功,就直接退出 //7.4.3 困难的串#include#include#include#include#includeusing namespace std;int n,L;int cnt;char v[81];bool judge(int cur){ for(int i=1;i>n>>L) { ...
阅读全文
摘要:题意:八皇后问题的扩展。8*8棋盘上每个格子都有一个整数,要求8个皇后所在格子的数字之后最大 解法一,回溯: 用vis数组记录 列,主对角(y-x), 副对角(y+x) 访问情况 #include#include#include#include#includeusing namespace std;int C[50], vis[3][50], tot = 0, n = 8, nc...
阅读全文
摘要:// Rujia Liu // 题意:给出n个带权集合,每个集合包含1~9中的三个整数。找出其中三个集合,使得1~9恰好各出现一次,且权和最大 // 算法:暴力n^2枚举前两个集合,直接计算出第三个集合。用位运算让代码更简单,速度也更快 学习点: 1、全集ALL为(1#include#includeusing namespace std;const int maxn = 1000 +...
阅读全文