摘要: // hnldyhy(303882171) 15:56:57 // poj 1988/*思路:找到含X的那叠箱子的箱子总数减去X上面的箱子数再减1就是所要的答案。如果a堆在b上,那么b上面的箱子数就是等于含a的那叠箱子的总数;*/#include #define N 30001int p[N];i... 阅读全文
posted @ 2014-08-10 20:03 2014acm 阅读(156) 评论(0) 推荐(0) 编辑
摘要: //1482#include #include using namespace std;int n,d;struct point{ int x,y,z,t;}a[1005];int find(int x ){ if(a[x].z==x) return x; else return ... 阅读全文
posted @ 2014-08-10 20:02 2014acm 阅读(100) 评论(0) 推荐(0) 编辑
摘要: //1481#include #include using namespace std;#define N 50010int parent[N],sum;void init(){ for(int i=1;in || y> n) {sum--;continue;} ... 阅读全文
posted @ 2014-08-10 20:01 2014acm 阅读(136) 评论(0) 推荐(0) 编辑
摘要: #include #includeusing namespace std;#define N 50010int p[N]; void init(int n){ for(int i=1 ;i#include #include #include #include #include using name... 阅读全文
posted @ 2014-08-10 19:59 2014acm 阅读(182) 评论(0) 推荐(0) 编辑
摘要: // hnldyhy(303882171) 17:07:57// poj 1703#include int p[200005];void init(int n){ for (int i=1;i#includeusing namespace std;#define N 500001int ... 阅读全文
posted @ 2014-08-10 19:52 2014acm 阅读(141) 评论(0) 推荐(0) 编辑
摘要: //1480#includeconst int MAX=50010; int p[MAX];int n,m;void init(int k) { for (int i=1; iconst int MAX=50010;int p[MAX];int n,m;void init(int k){fo... 阅读全文
posted @ 2014-08-10 19:47 2014acm 阅读(69) 评论(0) 推荐(0) 编辑
摘要: const int MAX=1010; //元素个数的最大值,根据题目修改int p[MAX];void init(int n) //n为实有元素个数{ for (int i=1; i<=n; i++) p[i]=i; }int find(int x) //查找{ if (x==p[x]) retu... 阅读全文
posted @ 2014-08-10 19:43 2014acm 阅读(92) 评论(0) 推荐(0) 编辑
摘要: //hnldyhy(303882171) 11:12:46// zoj 1649//bfs +优先队列#include #include #include using namespace std;struct node{ int x; int y; int step;};bool... 阅读全文
posted @ 2014-08-10 19:35 2014acm 阅读(366) 评论(0) 推荐(0) 编辑
摘要: //zoj 1586#include#includeusing namespace std;#define N 1005int a[N][N],low[N],n,ans;int b[N];int min(int x,int y){ return x#includeusing namespace... 阅读全文
posted @ 2014-08-10 19:31 2014acm 阅读(168) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;#define N 1005int a[N][N],low[N],n,ans;int b[N];int min(int x,int y){ return xci) { a[ai-1][bi-1]=c... 阅读全文
posted @ 2014-08-10 19:28 2014acm 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 输入:8 91 21 32 42 53 63 74 85 86 7// 图的BFS,使用C++队列#include #include #include using namespace std;#define N 10int g[N][N],bz[N],n,m;queue q;void BFS(in... 阅读全文
posted @ 2014-08-10 19:25 2014acm 阅读(238) 评论(0) 推荐(0) 编辑
摘要: #include // poj 1258 10.1.5.253 1505using namespace std; #define N 105 // 顶点的最大个数 (多写 int a[N][N],low[N],n,ans;int min(int x,int y){ ... 阅读全文
posted @ 2014-08-10 19:20 2014acm 阅读(97) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std;struct node{ char msg[20]; int a,b;};struct cmp{ bool operator()(const node ... 阅读全文
posted @ 2014-08-10 19:02 2014acm 阅读(214) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std; int main(){ vector phonelist; int testcast; cin >> testcast;... 阅读全文
posted @ 2014-08-10 19:00 2014acm 阅读(103) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std;int main(){ int n,i,j; string s; mapm; map :: iterator it,it2; while(cin>>n... 阅读全文
posted @ 2014-08-10 18:59 2014acm 阅读(139) 评论(0) 推荐(0) 编辑
摘要: #include#includeusing namespace std;int main(void){ while(true) { set s; int n, doubles = 0; while(cin>>n && n) { if(n == -1) ... 阅读全文
posted @ 2014-08-10 18:56 2014acm 阅读(179) 评论(0) 推荐(0) 编辑
摘要: #include #include#define N 10int g[N][N];int bz[N];int n,m ;void DFS(int cur){ int j; bz[cur]=1; printf("V%d",cur); for(j=1;j<=n ;j++ ) if(g[cur][j] ... 阅读全文
posted @ 2014-08-10 18:50 2014acm 阅读(196) 评论(0) 推荐(0) 编辑
摘要: // zoj 2110#include #include #include using namespace std;char map[9][9]; //迷宫地图int n,m,t; //迷宫的大小,及迷宫的门会在第t... 阅读全文
posted @ 2014-08-10 18:47 2014acm 阅读(131) 评论(0) 推荐(0) 编辑
摘要: greater 从小到大lesser 总大到小#include#includeusing namespace std;int main(){ int n,m,t,x,y; long long s; priority_queue ,greater > my; cin>>n; ... 阅读全文
posted @ 2014-08-10 18:33 2014acm 阅读(116) 评论(0) 推荐(0) 编辑
摘要: STL的队列和栈简单使用 #include #include #include #include #include #include using namespace std;int main(){ queue Q; stack S; int i; for(i=1;i M //例如 queue ... 阅读全文
posted @ 2014-08-10 18:25 2014acm 阅读(151) 评论(0) 推荐(0) 编辑