上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 57 下一页

2011年7月22日

poj 1466 Girls and Boys

摘要: #include <iostream> //二分最大匹配#include <vector>#include <algorithm>using namespace std;int n,link[500],match;bool visited[500];vector<int> col[500];bool dfs(int k){ for(int i=0;i<col[k].size();++i) { int x=col[k][i]; if(!visited[x]) { visited[x]=true; if( link[x]==-1 || dfs( 阅读全文

posted @ 2011-07-22 14:51 sysu_mjc 阅读(106) 评论(0) 推荐(0) 编辑

poj 1274 The Perfect Stall

摘要: #include <iostream> //二分最大匹配,参照poj 1466#include <vector>#include <algorithm>using namespace std;int n,m,link[210],match;bool visited[210];vector<int> col[500];bool dfs(int k){ for(int i=0;i<col[k].size();++i) { int x=col[k][i]; if(!visited[x]) { visited[x]=true; if( link[x 阅读全文

posted @ 2011-07-22 14:50 sysu_mjc 阅读(92) 评论(0) 推荐(0) 编辑

poj 1113 Wall

摘要: #include <iostream>#include <algorithm>#include <cmath>#define PI 3.1415926using namespace std;struct point { int x,y;}st;point castle[1005];double dis(point a,point b){ return sqrt(pow(a.x-b.x+0.0,2.0)+pow(a.y-b.y+0.0,2.0));}int cmp(const point& a,const point& b){ if((b.x- 阅读全文

posted @ 2011-07-22 14:49 sysu_mjc 阅读(112) 评论(0) 推荐(0) 编辑

poj 1056 IMMEDIATE DECODABILITY

摘要: // 题意: 输入一组01串,判断是否存在某个数是另外一个数的前缀。#include <iostream> // trie树using namespace std ;struct Node { int next[2]; int vis; //记录该节点所代表的号码是否出现过}table[100];int cur;void init(){ memset(table[0].next,-1,sizeof(table[0].next)); cur=1;}int prefix(char ch[]) //若出现前缀情况则返回 1{ N... 阅读全文

posted @ 2011-07-22 14:48 sysu_mjc 阅读(146) 评论(0) 推荐(0) 编辑

sicily 1024. Magic Island

摘要: #include<cstdio> //固定起点,求出到其它顶点的最长路径,邻接表+优先队列实现Dijkstra算法#include<cstring>#include<queue>#include <algorithm>using namespace std;const int INF = -1<<30;const int MAXN = 10000; const int MAXM = 20000; int n, m; //结点数和边数,结点下标从0开始int first[MAXN], distD[MAXN],done[MAXN];int 阅读全文

posted @ 2011-07-22 01:09 sysu_mjc 阅读(203) 评论(0) 推荐(0) 编辑

2011年7月21日

sicily 1448. Antimonotonicity

摘要: #include<iostream> //DP, 与sicily 1685. Missile 类似,但数据规模较大,O(n^2)肯定会TLE#include<stdio.h>using namespace std;int num[30010],ans[30010],odd,even; //ans[i]存放形成的序列上的第i个数,假若i表示偶数,则ans[i]<ans[i+1],所以第偶数上的值越小越好,而第奇数上的值越大越好int main(){ int t,n; cin>>t; while(t--) { scanf("%d",&a 阅读全文

posted @ 2011-07-21 21:38 sysu_mjc 阅读(203) 评论(0) 推荐(0) 编辑

sicily 1685. Missile

摘要: // 题意:有n个导弹,假若能摧毁4个导弹,则高度的要求:后面摧毁的导弹坐标要靠后// 而且第2个导弹比第1个导弹低,第3个导弹比第2个导弹高,第4个导弹比第3个导弹低// 即是偶数位的要比前面的低,而奇数位的要比前面的高#include<iostream> //DP, 最小不单调子序列, O(n^2)的时间复杂度,n<=1000,数据规模较小using namespace std;int n,h[1002],ans[1002][2]; // ans[i][0]表示以第i个数作为结束摧毁导弹的最大数量,此时第i个数在顺序上是偶,而ans[i][1]则表示第i个数在顺... 阅读全文

posted @ 2011-07-21 17:01 sysu_mjc 阅读(233) 评论(0) 推荐(0) 编辑

sicily 1048. Inverso

摘要: // 由于方格翻转两次就相当没有翻转,所以翻转的次数只可能取0,1,要么没翻,要么翻1次,// 这样初始状态为"wwwwwwwww",我们可以计算出每种翻转可能组合的结果,// 比如翻转 2459 后变成 bbwbwbwbw,那我们可以标记 bbwbwbwbw 的答案为 2459,// 因为 bbwbwbwbw 翻转 2459 后会变成 wwwwwwwww #include<iostream> //数据量小,直接枚举#include<cstring>#include<vector>using namespace std;int mov[1 阅读全文

posted @ 2011-07-21 11:59 sysu_mjc 阅读(373) 评论(0) 推荐(0) 编辑

sicily 1813. M进制数问题

摘要: #include<iostream> //先把m进制整数A和B转化成十进制,计算出A/B与A%B的十进制值,结果用m进制表示#include<math.h>#include<string.h>using namespace std;int t,m;int to_dec(char ch[]) //m进制转化成十进制{ int n=0; double k=0; for(int i=strlen(ch)-1;i>=0;i--) { if(ch[i]>='0'&&ch[i]<='9') n+=(ch[ 阅读全文

posted @ 2011-07-21 10:24 sysu_mjc 阅读(313) 评论(0) 推荐(0) 编辑

sicily 1073. Pearls

摘要: #include <iostream> //DP#include <numeric>using namespace std;#define ed 105int ai[ed],pi[ed],dp[ed]; int main(){ int t,c; cin>>t; while(t--) { cin>>c; for(int i=1;i<=c;++i) cin>>ai[i]>>pi[i]; fill(dp,dp+ed,100000000); //初始化为极大值 dp[0]=0; for(int i=1;i<=c;++i 阅读全文

posted @ 2011-07-21 01:43 sysu_mjc 阅读(131) 评论(0) 推荐(0) 编辑

上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 57 下一页

导航