上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 26 下一页
摘要: 一道dp题,虽然知道是dp,但是不会做;学习了ACM_cxlove大神的代码,终于明白了;搬运工:dp[i][j][k]表示 前i个已经完全匹配,而这时候,第i+1个已经加了j位,第i+2位已经加了k转移分为两步,枚举加,枚举减;上面是大神的原话,不过看了好久的代码才明白;下面是我的一点领悟: 1 #include 2 #include 3 #include 4 #define inf 1<<20 5 #define N 1005 6 using namespace std; 7 char s1[N],s2[N]; 8 int dp[N][10][10]; 9 int main() 阅读全文
posted @ 2013-09-25 17:03 Yours1103 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 一道枚举+搜索题;很容易看出这道题目要求尽量不在大的城市里面建加油站;所以从最大的城市开始枚举!代码: 1 #include 2 #include 3 #include 4 #define maxn 130 5 #include 6 using namespace std; 7 8 struct node 9 {10 double x,y;11 } no[maxn];12 queueq;13 int dis[maxn][maxn],n,d,dd[maxn];14 bool vis[maxn],flag[maxn];15 16 bool bfs()17 {18 while(!q... 阅读全文
posted @ 2013-09-25 15:04 Yours1103 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 计算几何+数值计算的题目;要用到辛普森积分,没有学过~~~参考学习了 acm_Naruto大神的代码!代码: 1 #include 2 #include 3 #include 4 #define maxn 20005 5 using namespace std; 6 int n,a,b,c,l,r,x[maxn],y[maxn]; 7 double sqr(double x) 8 { 9 return x*x;10 }11 double len(double x)12 {13 double t,tt;14 t=(sqrt((b+2*a*x)*(b+2*a*x)+1)+2... 阅读全文
posted @ 2013-09-24 00:08 Yours1103 阅读(362) 评论(0) 推荐(0) 编辑
摘要: 参考阳神的博客写的,非常好的一个方法。题目的意思是: 对于每对点 找出他们之间所有路径中 最长边 的最小值~~~好拗口的!思路: 直接找出满足要求的太过于麻烦;所以找出不满足条件的,然后用总的数目(n*(n-1))减去不满足的就行;做法: 因为找的是最长边,所以首先将边和查询都按从小到大排好序。因为满足要满足条件,查询的值要比当前已经访问的边的值要大; 另外,访问了边之后要维护,选用并查集!感觉这个方法很正确,但是不会证明 = =!代码: 1 #include 2 #include 3 #define maxn 10005 4 #define maxm 500005 5 using n... 阅读全文
posted @ 2013-09-23 22:28 Yours1103 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 题目很简单,不过题意很难看懂。就是给一个标准的大小关系的队列,从原队列中找出最多的匹配子队列,感觉就像一个KMP算法+贪心;不过这个题可能数据有点水把,竟然只要判断相邻的关系就可以A掉;代码: 1 #include 2 #define maxn 100005 3 using namespace std; 4 int q[maxn],st[maxn],n,m,k; 5 6 bool g(int a) 7 { 8 int i; 9 for(i=a; iq[i+1]&&st[i-a]>st[i-a+1]))continue;12 else break;13 ... 阅读全文
posted @ 2013-09-23 16:36 Yours1103 阅读(331) 评论(0) 推荐(1) 编辑
摘要: 一道很简单的题,不过在比赛的时候没有写出来;刚刚看到这个题,我以为是一个图论题,后来发现其实就是一个暴力的题;用bfs,因为一个人与他不认识的人肯定不会在一个集合,如果判断出现冲突则分配失败,否则就成功;代码: 1 #include 2 #include 3 #include 4 #define maxn 103 5 using namespace std; 6 7 int map[maxn][maxn],n; 8 int b[maxn]; 9 10 bool bfs(int a)11 {12 queueq;13 q.push(a);14 while(!q.empty... 阅读全文
posted @ 2013-09-23 12:52 Yours1103 阅读(357) 评论(0) 推荐(1) 编辑
摘要: 昨天和今天打了南京和长沙的网络邀请赛,我们被虐的很惨,其实并不只是我们队伍,我们学校都输的很惨。 昨天的南京赛,我开了第四题,小珺和小骐一起开了第三题。南京赛的题目读得挺纠结的,把第四题读完我就没有心思再去看其他的题目了;第四题其实是个暴力,也应该可以把它变成一个图论题来做,但昨天硬是出不了,当时想到了一个可能的出错点,感觉好麻烦的,就懒得去写了。昨天的心态也不好,脑袋也有点痛,加上表姨一个劲儿地用打我电话,让本来的比赛变得没有一点感觉。看着小骐和小珺在旁边开心的讨论,心里感觉一点都不是滋味,后来干脆就落井下石了——不干活,玩手机去了。这次比赛确实是坑了队友,唉~~~我承认我错了,但我也... 阅读全文
posted @ 2013-09-22 23:26 Yours1103 阅读(222) 评论(0) 推荐(1) 编辑
摘要: 一道超级easy的贪心一眼看出了他的本质;代码: 1 #define mod 31536000 2 #include 3 #include 4 #include 5 #define maxn 100005 6 using namespace std; 7 8 struct node 9 {10 int a,b;11 double ave;12 bool operator <(const node &t)const13 {14 if(ave==t.ave) return a<t.a;15 return ave<t.ave;16 ... 阅读全文
posted @ 2013-09-18 22:16 Yours1103 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 今天模拟赛的一个模拟题;每次看到这种题就感觉很繁琐;这次静下心来写写,感觉还不错!就是很多错误,浪费了一点时间;代码: 1 #include 2 #include 3 using namespace std; 4 5 int d[4][2]= {{1,0},{0,1},{-1,0},{0,-1}}; 6 7 struct run 8 { 9 int x,y;10 int s,p,d;11 } r[2];12 int t,n;13 void go()14 {15 bool flag;16 for(int i=0; in)37 {38 ... 阅读全文
posted @ 2013-09-18 22:14 Yours1103 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 今天模拟了一场去年金华的现场赛;我和小珺两人出了5个题,感觉还可以;不过这次的题目确实比较简单;这个题目感觉不错,不难,以前见过用这种方法的,但一直没写过;这次写下练练手:思路,将角度分成1000份,然后暴力;代码: 1 #include 2 #include 3 #include 4 #define du 0.003141593 5 #define g 9.8 6 #define eps 0.0000001 7 using namespace std; 8 9 int ans,n;10 double dan[205],h,l1,r1,l2,r2;11 12 void go()13 {14 . 阅读全文
posted @ 2013-09-18 22:10 Yours1103 阅读(216) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 26 下一页