上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 57 下一页

2011年7月22日

poj 1270 Following Orders

摘要: // 给出一个字母表和一些字母对(c1,c2)表示c1<c2// 求出所有满足要求的排列,并按照字典序输出#include<iostream> //拓扑排序 + dfs#include<algorithm>#include<string>using namespace std;int dict[30],edge[30][30],vis[30],rear,path[30],in[30];void topo_sort(int pos){ if(pos==rear) { for(int i=0;i<rear;++i) cout<<char( 阅读全文

posted @ 2011-07-22 22:29 sysu_mjc 阅读(182) 评论(0) 推荐(0) 编辑

poj 1254 Hansel and Grethel

摘要: #include<iostream> //求两直线交点,交点是存在的#include<stdio.h>#include<cmath>using namespace std;#define pi acos(-1.0)int main(){ int cases; double x1,y1,d1,x2,y2,d2,k1,k2,x,y; cin>>cases; while(cases--) { cin>>x1>>y1>>d1>>x2>>y2>>d2; k1=tan((450-d1)* 阅读全文

posted @ 2011-07-22 22:28 sysu_mjc 阅读(176) 评论(0) 推荐(0) 编辑

poj 1256 Anagram

摘要: #include<iostream>#include<string>#include<algorithm>using namespace std;int cmp(char a,char b) //'A'<'a'<'B'<'b'<...<'Z'<'z'.{ if(tolower(a)!=tolower(b)) return tolower(a)<tolower(b); else return a<b;}int main 阅读全文

posted @ 2011-07-22 22:28 sysu_mjc 阅读(117) 评论(0) 推荐(0) 编辑

poj 1252 Euro Efficiency

摘要: // 给出6枚不同面值(在1到100之间)的硬币,通过 加减(注意可以减)凑出1到100的钱数,我们关心的是最少要用到几枚硬币,// 最后求出平均值,并找出其中最大值#include<iostream> // BFS最短路搜索#include<stdio.h>#include<algorithm>#include<numeric>using namespace std;int euro[20],q[200],cnt[200],vis[200];int main(){ int cases,i; scanf("%d",&c 阅读全文

posted @ 2011-07-22 22:26 sysu_mjc 阅读(198) 评论(0) 推荐(0) 编辑

poj 1129 Channel Allocation

摘要: //参考 poj9 1620 Phone Home#include<iostream> //求图的色数,即使各相邻顶点的颜色不相同所需的最小色数.数据量小,直接枚举+DFS#include<stdio.h>#include<cstring>using namespace std;int n,cnt[30][30],color[30],num,suc;void dfs(int i){ for(int c=1;c<=num;++c) { int flag=1; for(int j=0;j<n;++j) if(cnt[i][j]==1&& 阅读全文

posted @ 2011-07-22 22:20 sysu_mjc 阅读(184) 评论(0) 推荐(0) 编辑

poj 1094 Sorting It All Out

摘要: // 题意:给出n个字母和一系列不等式,判断是否能确定所有字母顺序// 输出在最早在第几个不等式处可以确定下唯一的顺序或判断出矛盾,或者到最后也无法确定唯一的顺序#include<iostream> //拓扑排序using namespace std;int table[26][26],path[26],in[26],origin_in[26]; //in表示入度数int main(){ char ch[4]; int n,m,a,b; while(cin>>n>>m&&n) { memset(table,0,sizeo... 阅读全文

posted @ 2011-07-22 22:17 sysu_mjc 阅读(110) 评论(0) 推荐(0) 编辑

poj 3753 根据关键字进行字符串拷贝

摘要: #include<iostream>#include<string>using namespace std;int main(){ string str1,str2; while(cin>>str1) { while(cin>>str2&&str2!="END") { if(str2=="NULL") { printf("0 NULL\n");continue; } int id=str1.find(str2); if(id==0) { printf("0 NU 阅读全文

posted @ 2011-07-22 20:43 sysu_mjc 阅读(155) 评论(0) 推荐(0) 编辑

poj 3349 Snowflake Snow Snowflakes

摘要: #include<iostream> //哈希函数,拉链法#include<vector>using namespace std;const int mv=99991;int data[100002][6];vector<int> hash[100002];bool same(int a[6],int b[6]) //a[]的下标j总是从0到6,固定a,而b[]的起始下标i从0到6,绕顺时针(向右)和逆时针旋转{ int tag; for(int i=0;i<6;++i) { tag=0; for(int j=0;j<6;++j) { if(a[ 阅读全文

posted @ 2011-07-22 20:42 sysu_mjc 阅读(117) 评论(0) 推荐(0) 编辑

poj 3667 Hotel

摘要: // 题意: 旅店登记,有n个房间,有两种操作: 1.找一段最靠前的连续d个空房间; 2.退订[x,x-d+1]段的房间#include<iostream> //线段树using namespace std;struct node{ int l,r,blank; int lb,rb; //lb(rb)记录从左(右)端点开始的连续空的线段长}tree[200010];void build_tree(int n,int s,int t){ tree[n].l=s;tree[n].r=t; tree[n].blank=tree[n].lb=... 阅读全文

posted @ 2011-07-22 20:42 sysu_mjc 阅读(195) 评论(0) 推荐(0) 编辑

poj 3259 Wormholes

摘要: /* 题意:John的农场里n块地,M条路连接两块地,是双向边, W个虫洞,虫洞是一条单向路,不但会把你传送到目的地,而且时间会倒退w秒。 问能否在从某块地出发后又回来,看到了离开之前的自己,即求负权回路 思路:Bellman-Ford算法,源点不明确,求负权回路 当源点不明确时: 与SPFA算法不同,当源点不明确时,Bellman-Ford算法不用添加超源点, 因为它对图中每一条边都会做n-1次松弛,就保证每个顶点都得到更新。 对于此题,如何控制初值,一个比较原始的想法是,枚举起点,这样的时间复杂度大约为O(n^4),但是还是可以过... 而经过观察发现,假设有一个原点0,到所有点的距离都. 阅读全文

posted @ 2011-07-22 20:41 sysu_mjc 阅读(162) 评论(0) 推荐(0) 编辑

上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 57 下一页

导航