算法竞赛入门经典
算法竞赛入门经典(紫书),例题中一些比较有学习意义的题。
Tech_hysteria
We are all in the gutter,but some of us are looking at the stars.
展开
-
UVA#1220Party at Hali-Bula
描述:类似于最大独立集,略。#include<iostream>#include<string>#include<vector>#include<map>using namespace std;const int MAX = 210;int n,num,d[MAX][2],f[MAX][2];vector<int> su...原创 2020-03-07 21:15:58 · 79 阅读 · 0 评论 -
UVA#12186Another Crisis
描述:略#include<iostream>#include<vector>#include<algorithm>using namespace std;const int MAX = 100010;int T;vector<int> sub[MAX];//某个员工的直接下属 int dp(int p){ if(sub[p].em...原创 2020-03-07 15:41:32 · 77 阅读 · 0 评论 -
UVA#11584Partitioning by Palindromes
描述切割回文#include<iostream>#include<cstring>using namespace std;const int INF = 10000;int d[1005];int ispa[1005][1005],vis[1005][1005];char a[1010];int l;//int ispan(int s,int e){//...原创 2020-03-06 09:52:18 · 100 阅读 · 0 评论 -
UVA12563劲歌金曲
描述:略#include<iostream>#include<cstring>#include<algorithm>using namespace std;int song[55],d[55][180 * 50 + 678];//前i首歌,刚好是j秒的最多歌数,这样就和01背包一样啦。int main(){ //freopen("d://poj/...原创 2020-03-05 15:43:40 · 113 阅读 · 0 评论 -
UVA#1025A Spy in the Metro
描述略#include<iostream>#include<cstring>#include<algorithm>using namespace std;int d[205][55];//时刻i在车站j,至少等多久int train[205][55][2];//时刻i在车站j,是否有车int tp[55];//车站间隔const int INF ...原创 2020-03-03 22:32:54 · 92 阅读 · 0 评论 -
计蒜客#T1408矩形嵌套
有 nn 个矩形,每个矩形可以用 a,ba,b 来描述,表示长和宽。矩形 X(a,b)X(a,b) 可以嵌套在矩形 Y(c,d)Y(c,d) 中当且仅当 a <c,b<da<c,b<d 或者 b<c,a<db<c,a<d(相当于旋转 9090 度)。例如(1,51,5)可以嵌套在(6,26,2)内,但不能嵌套在(3,43,4)中。你的任务是选出尽可能...原创 2020-03-03 14:35:56 · 232 阅读 · 0 评论 -
UVA#10603Fill
倒水问题Sample Input22 3 4 296 97 199 62Sample Output2 29859 62#include<iostream>#include<cstring>#include<queue>#include<algorithm>using namespace std;const int M...原创 2020-02-28 16:48:58 · 67 阅读 · 0 评论 -
百练#1077Eight(hash实例)
描述八数码问题,目标固定为123456780,输出路径。输入You will receive a description of a configuration of the 8 puzzle. The description is just a list of the tiles in their initial positions, with the rows listed from to...原创 2020-02-28 14:18:44 · 187 阅读 · 0 评论 -
UVA-140 Bandwidth
带宽Sample InputA:FB;B:GC;D:GC;F:AGH;E:HD#Sample OutputA B C F G D H E -> 3#include<cstdio>#include<iostream>#include<vector>#include<string>#include<cstring&...原创 2020-02-27 17:06:20 · 110 阅读 · 0 评论 -
uva#129Krypton Factor
困难的串Sample Input7 330 30 0Sample OutputABAC ABA7ABAC ABCA CBAB CABA CABC ACBA CABA28#include<iostream>using namespace std;int n,l,cnt;int s[80];int dfs(int cur){ int i,j,k,ok; if...原创 2020-02-27 11:05:46 · 55 阅读 · 0 评论 -
uva#524Prime Ring
素数环A ring is composed of n (even number) circles as shown in diagram.Put natural numbers 1, 2, . . . , n into each circle separately, and thesum of numbers in two adjacent circles should be a prime...原创 2020-02-26 15:37:21 · 67 阅读 · 0 评论 -
UVA#12096The SetStack Computer
• PUSH will push the empty set {} on the stack.• DUP will duplicate the topmost set (pop the stack, and then push that set on the stack twice).• UNION will pop the stack twice and then push the unio...原创 2020-02-21 14:11:33 · 86 阅读 · 0 评论