5 Intelligence1028

尚未进行身份认证

我要认证

每天提高一点点

等级
TA的排名 2w+

HDU 1554(Pairs of integers)

#include <iostream>#include <map>#include <iomanip>using namespace std;int N;int H, S, L;int X;map<int, int> res, ri;int main(){ while (cin >> N) { res.clear(); ri.clear(); for (int i = 0, num = 1; num <.

2020-06-03 09:59:59

HDU 1551(Cable master)

基础题,二分查找即可。#include <iostream>#include <iomanip>using namespace std;const int MAXN = 10005;const double eps = 1e-6;double len[MAXN]; //每段绳子的长度int N, K;//判断是否能得到K段长为x的绳子bool check(double x) { int total = 0; for (int i = 0; i <

2020-06-02 10:40:01

HDU 1548(A strange lift)

广搜题,每次搜索上下两个方向即可。#include <iostream>#include <cstring>#include <queue>using namespace std;const int MAXN = 205;int N; //楼层数int s, e; //起点,终点int num[MAXN]; //每层可以上下的楼层数int vis[MAXN]; //访问情况int step[MAXN]; //到达各层时的步数//广搜int

2020-06-01 11:33:55

HDU 1547(Bubble Shooter)

#include <iostream>#include <cstring>#include <queue>using namespace std;const int MAXN = 105;int R, C;char mp[MAXN][MAXN]; //地图int s[MAXN * MAXN];int dir[2][6][2] = //搜索方向{ {{0,-1},{0,1},{-1,0},{1,0},{-1,1},{1,1} }, //偶数行.

2020-05-31 20:30:39

HDU 1546(Idiomatic Phrases Game)

使用Dijkstra算法,首先建立有向图,将每个单词作为一个结点,和能直接接在其后的单词连线,然后计算起点到终点的最短距离即可。#include <iostream>#include <cstring>using namespace std;const int MAXN = 1005;const int INF = 0x3f3f3f3f;struct Word //单词{ int time; //查找后续单词所需时间 char first[5], last[.

2020-05-30 15:55:55

HDU 1545(01-K Code)

动态规划题,设 dp[i][j][k] 表示长为 i 的子序列中,0 比 1 最多多 j 个,1 比 0 最多多 k 个。如果第 i+1 位填0,则 dp[i + 1][j + 1][max(k - 1, 0)] += dp[i][j][k];如果第 i+1 位填1,则 dp[i + 1][max(j - 1, 0)][k + 1] += dp[i][j][k]。#include <iostream>#include <cstring>#include <al

2020-05-29 10:30:00

HDU 1544(Palindromes)

基础题,将原字符串中每一个字符作为回文子串的中心点,按照子串长度为奇数和偶数向两边扩展即可。#include <iostream>#include <string>using namespace std;int main(){ string s; while (cin >> s) { int len = s.size(); int ans = 0; int l, r; for (int i = 0; i < len; i++)

2020-05-28 23:59:58

HDU 1543(Paint the Wall)

由于数据量很小,直接将每个矩形离散化,即拆分成小正方形,并记录每个小正方形的颜色,最后扫描一遍全图即可。#include <iostream>#include <algorithm>#include <cstring>using namespace std;const int MAXN = 105;int X[MAXN * 2]; //所有左上角和右下角的X坐标int Y[MAXN * 2]; //所有左上角和右下角的Y坐标int color[MAX

2020-05-27 17:17:16

HDU 1542(Atlantis)

#include <iostream>#include <algorithm>#include <iomanip>using namespace std;const int MAXN = 205;struct Line { double x; double y1, y2; int flag;}line[MAXN];double y[MAXN];double wide[MAXN * 4];int num[MAXN * 4];int cmp.

2020-05-26 16:16:16

HDU 1541(Stars)

#include <iostream>#include <cstring>using namespace std;const int MAXN = 32005;int tree[MAXN << 2], num[MAXN << 2];int x, y;int level;void insert(int l, int r, int i){ if (l == r) level += tree[i]; else .

2020-05-25 14:44:45

HDU 1540(Tunnel Warfare)

#include <iostream>#include <stack>using namespace std;const int MAXN = 50005;int L[4 * MAXN], R[4 * MAXN];int flag;void build(int l, int r, int rt){ L[rt] = R[rt] = r - l + 1; if (l == r) return; int m = (l + r) >> 1; bui.

2020-05-24 14:20:00

HDU 1539(Shredding Company)

深搜题。#include <iostream>#include <cstring>using namespace std;const int MAXN = 25;int n; //目标数字char str[MAXN]; //输入带int len; //输入带长度int ans, flag; //满足要求的最大和int tmpPath[MAXN]; //临时路径int tmpIdx;int path[MAXN]; //最终路径int idx;void

2020-05-23 12:19:59

HDU 1538(A Puzzle for Pirates)

#include <iostream>#include<cstdio>#include<ctime>#include<cstring>#include<cmath>#include<algorithm>#include<cstdlib>#include<vector>#define C 240#define TIME 10#define inf 1<<25#define.

2020-05-22 12:40:01

HDU 1536(S-Nim)

SG函数题,套用标准模板即可。#include <iostream>#include <cstring>using namespace std;int sg[10005], num[105];int k;//计算sg[x]int getSG(int x){ if (sg[x] != -1) return sg[x]; bool vis[105]; memset(vis, 0, sizeof(vis)); for

2020-05-21 18:18:18

HDU 1535(Invitation Cards)

使用 Dijkstra算法,首先构造正向图,计算从起点到达其余结点的最短距离;然后将正向图的所有边反向,构造反向图,再计算从起点到达其余结点的最短距离,此距离等于正向图中,从其余结点到达起点的最短距离。将两距离相加,即为从起点到达其余结点再返回起点的最短距离。由于结点数很多,所以采用 vector 结构构造地图,在 Dijkstra 算法中采用优先队列。#include <iostream>#include <vector>#include <cstring&gt

2020-05-20 16:50:01

HDU 1534(Schedule Problem)

#include <iostream>#include <cstring>#include <string>#include<algorithm>#include<cstdio>#include<queue>using namespace std;const int MAXN = 1005;const int INF = 0x3f3f3f3f;struct Edge{ int to, cost, n.

2020-05-19 10:19:59

HDU 1533(Going Home)

#include <iostream>#include <cstring>#include <cmath>#include <queue>using namespace std;const int MAXN = 105;const int MAXK = 5005;const int INF = 0x3f3f3f3f;struct Edge{ int y, next; int v, c;}edge[MAXK * MAXK];cha.

2020-05-18 11:30:01

HDU 1532(Drainage Ditches)

网络流问题,使用最大流EK算法。#include <iostream>#include <cstring>#include <queue>#include <algorithm>using namespace std;const int MAXN = 205;const int INF = 0x3f3f3f3f;int C[MAXN][MAXN]; //C[i][j]表示结点i到结点j的剩余流量 int V[MAXN]; //V[i]表

2020-05-17 17:00:00

HDU 1531(King)

#include <iostream>#include <vector>#include<cstring>#include<queue>#include<cstdio>#include<algorithm>using namespace std;const int MAXN = 105;const int INF = 0x3f3f3f3f;struct Edge //边{ int to; //终点.

2020-05-16 11:20:00

HDU 1530(Maximum Clique)

计算最大团的结点数量,套用标准模板即可,详细见注释。#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 55;int n; //图中结点数量int ans; //最大团中结点的数量int mp[MAXN][MAXN]; //结点之间的连接关系int select[MAXN]; //当前最大团中的结点int num

2020-05-15 09:50:00

查看更多

勋章 我的勋章
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
  • 勤写标兵Lv4
    勤写标兵Lv4
    授予每个自然周发布9篇以上(包括9篇)原创IT博文的用户。本勋章将于次周周三上午根据用户上周的博文发布情况由系统自动颁发。