
ACM和算法
Wu_Being
这个作者很懒,什么都没留下…
展开
-
【OJ】总结ACM编程易错点
1285开始用STL编程1286 约瑟夫环1098 归并排序1261 C语言8.271023 坑爹的黑店(水题)1059 1065 图砖1068 计算并集 移动的盒子(Boxes in a Line,UVa 12657)#include#includeusing namespace std;int shu[100010]={0};int main原创 2014-09-23 14:03:10 · 1874 阅读 · 0 评论 -
【OJ】A*(start)算法c++初步实现
<span style="font-size:14px;">/* A* 算法 2014/11/5 吴成兵 改进中 BFS是A*算法中最笨的一种 */#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include&..原创 2014-11-05 23:49:01 · 773 阅读 · 0 评论 -
四皇后问题(同理适用于n皇后问题)图片版
四皇后问题(同理适用于n皇后问题 图片版)图片来源:《数据结构 C语言版》(严蔚敏 吴伟民 编著 )第151页转载 2016-10-24 21:39:14 · 6271 阅读 · 0 评论 -
【OJ】1032:一家人
#include #include int s[22]={0};int main(){ int n; int a,b; while(scanf("%d",&n)!=EOF) { memset(s,0,sizeof(s)); int i; for(i=0;i<n;i++) { scanf("%d%d",&a,&b); s[a]=b; } int原创 2014-11-04 21:50:22 · 715 阅读 · 0 评论 -
【OJ】DP 01背包 记忆化搜索 O(nW)
/* 01背包 记忆化搜索 O(nW)*/#include#include#include#define MAX_N 101#define MAX_W 3001using namespace std;//最多有3000元,dp[][3001]<-solve(0,3000)int w[101],v[101],n,W,dp[MAX_N][MAX_W];int solve(int i原创 2014-10-23 20:24:23 · 1055 阅读 · 0 评论 -
【OJ】贪心法(最小字典序)poj3617 Best Cow Line// acmclub 12701/12695
/* POJ 3617 Best Cow Line 贪心法——最小字典序 */ #in原创 2014-10-18 11:39:50 · 739 阅读 · 0 评论 -
【OJ】贪心法 (区间问题——木棒)1129/
#include #include #include using namespace std; const int maxn=5010; typedef pair P; pairitv[maxn]; int ok[maxn]; bool comp( P a,const P & b){ //const & if (a.second==b.second)return a.first>t; while(原创 2014-10-16 22:27:33 · 888 阅读 · 0 评论 -
【OJ】贪心法 Saruman's Army POJ 3069 /acmclub 12132
题目链接:点击打开链接原创 2014-10-20 00:53:47 · 575 阅读 · 0 评论 -
【OJ】贪心法 Fence Repair POJ 3253 霍夫曼(Huffman)编码原理 acmclub 12326
题目链接:/* 贪心法 Fence Repair POJ 3253 霍夫曼(Huffman)编码原理 */#include#includetypedef long long LL;using namespace std;int l[50010];int main(){ int j,m=0,n;cin>>n; LL s=0,ans=0; for(int i=0;i>l原创 2014-10-20 00:53:03 · 885 阅读 · 0 评论 -
【OJ】迷宫最短路径问题(maze)acmclub.com 1102
#include#include#includeusing namespace std;int yy,xx,sx,sy,ex,ey,d[101][101]={0};char c,maze[101][101];int dx[4]={-1,1,0,0},dy[4]={0,0,1,-1};struct NODE{ int nx,ny;}node1,node2;vo原创 2014-10-16 13:18:23 · 1317 阅读 · 0 评论 -
【OJ】排列 n! STL函数next_permutation // Anagram / hzu.acmclub.com10317 / poj 1256
1 /* 2 排列 n! poj1256 Anagram 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std; 10 bool cmp(char a,char b){//'A'n; 19 while(n--){ 20 scanf("%s",ch); 21 // sort(ch,ch+原创 2014-10-19 14:38:23 · 579 阅读 · 0 评论 -
【OJ】Red and black poj1979 // acmclub.com 6659
#include#includeusing namespace std;char tiles[21][21];int x,y,w,h,ans;int dx[4]={-1,0,0,1},dy[4]={0,-1,1,0};//^<>void dfs(int sx,int sy){ ans++;tiles[sy][sx]='#'; for(int i=0;i<4;i++){ int原创 2014-10-16 00:22:07 · 712 阅读 · 0 评论 -
【OJ】贪心——区间问题 hzu.acmclub.com 1126看电视
/*贪心——区间问题 hzu.acmclub.com 1126看电视 */#include#includeusing namespace std;//typedef pair P; /////////////用pair//P tv[101];//bool comp(P a,const P &b){//// if(a.second<b.second)return true;//1原创 2014-10-18 23:10:43 · 1584 阅读 · 0 评论 -
【OJ】Ants acmclub.com 10913 // poj 1852
#include#include#includeusing namespace std;int shu[1000010];int main(){ int i,a,b; while(scanf("%d %d",&a,&b)!=EOF){ for( i=0;i<a;i++) scanf("%d",&shu[i]); sort(shu,shu+a);原创 2014-10-16 00:12:32 · 921 阅读 · 0 评论 -
【OJ】Lake Counting (Poj 2386 // hzu.acmclub.com 11448)
#include#includeusing namespace std;int n,m,ans=0;char f[101][101];void dfs(int r,int c){ f[r][c]='.'; for(int dr=-1;dr for(int dc=-1;dc int rr=r+dr,cc=c+dc; if(rr>=1&&rr=1&&c原创 2014-10-14 21:21:42 · 863 阅读 · 0 评论 -
【OJ】1.6.7将军(Check the Check)UVa 10196 // PC 1101017 // acmclub.com 25177
/* 1.6.7将军(Check the Check)UVa 10196 // PC 1101017 */#include#includeusing namespace std;char a[10][10];int x,y,X,Y; int white=0,black=0;/////////////////////////////////blackkvoid原创 2014-10-14 20:29:31 · 778 阅读 · 0 评论 -
【OJ】2014广东省ACM热身赛题目
版权 A.Query (查询)描述 给你一个数列{A1,A2,...An},并要求支持一系列如下的操作和查询: 1.ADD x y D:把D加到每个子序列{Ax... Ay}中。比如,执行“ADD 2 4 1”,使{1,2,3,4,5}变成{1,3,4,5,5} 2.REVERS x y:反转子序列{Ax... Ay}。例如,执行“REVERSE 2翻译 2014-09-23 14:13:46 · 952 阅读 · 0 评论 -
翻转链表算法和实现
写个翻转链表算法,刚开始想到一个不错的思路。这个思路运行效率不低,时间复杂度为O(n);可以不用分配额外的节点空间,空间复杂度为O(0)。现在把思路整理一下,并实现代码,测试运行结果。原创 2017-11-02 12:39:53 · 1969 阅读 · 0 评论