休眠了2月了 要振作起来了!!。。。

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2155

因为点比较少 最多更新三百次 标记某个节点时直接更新与之相连的点的最短距离

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
#define INF 0xfffffff
int w[][],f[];
int main()
{
int n,m,i,j,q;
int kk = ;
while(cin>>n>>m>>q)
{
if(n==&&m==&&q==) break;
int u,v,c;
memset(f,,sizeof(f));
for(i = ; i < n ; i++)
{
for(j = ;j < n ; j++)
w[i][j] = INF;
w[i][i] = ;
}
for(i = ; i <= m ; i++)
{
cin>>u>>v>>c;
w[u][v] = min(w[u][v],c);
}
printf("Case %d:\n",kk++);
while(q--)
{
int t;
cin>>t;
if(t==)
{
int x,y;
cin>>x>>y;
if(!f[x]||!f[y])
printf("City %d or %d is not available.\n",x,y);
else if(w[x][y]==INF)
puts("No such path.");
else
printf("%d\n",w[x][y]);
}
else
{
int x;
cin>>x;
if(f[x])
{
printf("City %d is already recaptured.\n",x);
continue;
}
f[x] = ;
for(i = ; i < n ; i++)
for(j = ; j < n ; j++)
if(w[i][j]>w[i][x]+w[x][j])
w[i][j] = w[i][x]+w[x][j];
}
}
puts("");
}
return ;
} /**************************************
Problem id : SDUT OJ 2155
User name : shang
Result : Accepted
Take Memory : 832K
Take Time : 300MS
Submit Time : 2014-01-16 15:11:20
**************************************/

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2159

set存结构体 low_bounder二分查找 不过时间跑了不少 不知道有没有更简单的方法

 #include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
using namespace std;
struct node
{
int x,y;
bool operator <(const node a) const
{
if(a.x==x)
return y<a.y;
return x<a.x;
}
};
char s[];
int main()
{
int n,kk=;
while(cin>>n)
{
if(!n) break;
set<node>q;
node st;
printf("Case %d:\n", kk++);
while(n--)
{
cin>>s;
if(s[]=='a')
{
cin>>st.x>>st.y;
q.insert(st);
}
else if(s[]=='f')
{
cin>>st.x>>st.y;
set<node>::iterator it;
it = q.lower_bound(st);
while(it!=q.end())
{
if((*it).x>st.x&&(*it).y>st.y)
{
cout<<(*it).x<<" "<<(*it).y<<endl;
break;
}
it++;
}
if(it==q.end())
puts("-1");
}
else
{
cin>>st.x>>st.y;
q.erase(st);
}
}
puts("");
}
return ;
} /**************************************
Problem id : SDUT OJ 2159
User name : shang
Result : Accepted
Take Memory : 2572K
Take Time : 930MS
Submit Time : 2014-01-16 17:34:20
**************************************/

http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2157

先取两个数 再二分查找和与m最近的数

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
using namespace std;
int a[],p[*];
int main()
{
int n,m,i,j;
int kk = ;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(!n&&!m) break;
for(i = ; i < n ; i++)
scanf("%d",&a[i]);
a[n] = ;
int g = ;
for(i = ; i <= n; i++)
for(j = i ; j <= n ; j++)
if(a[i]+a[j]<=m)
p[g++] = a[i]+a[j];
sort(p,p+g);
int maxz = ;
printf("Case %d: ",kk++);
for(i = ; i < g ; i++)
{
if(p[i]>m) break;
int low = i,high = g-;
while(low<high)
{
int mm = (low+high)/;
if(p[i]+p[mm]>m)
high = mm-;
else
low = mm+;
}
if(p[low]+p[i]<=m&&p[low]+p[i]>maxz)
{
maxz = p[low]+p[i];
}
}
printf("%d\n",maxz);
puts("");
}
return ;
} /**************************************
Problem id : SDUT OJ 2157
User name : shang
Result : Accepted
Take Memory : 2444K
Take Time : 130MS
Submit Time : 2014-01-16 15:43:45
**************************************/

2010山东省第一届ACM程序设计竞赛的更多相关文章

  1. Emergency(山东省第一届ACM程序设计真题+Floyd算法变型)

    题目描述 Kudo’s real name is not Kudo. Her name is Kudryavka Anatolyevna Strugatskia, and Kudo is only h ...

  2. Shopping(山东省第一届ACM省赛)

    Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...

  3. 华南师大 2017 年 ACM 程序设计竞赛新生初赛题解

    题解 被你们虐了千百遍的题目和 OJ 也很累的,也想要休息,所以你们别想了,行行好放过它们,我们来看题解吧... A. 诡异的计数法 Description cgy 太喜欢质数了以至于他计数也需要用质 ...

  4. 第十四届中北大学ACM程序设计竞赛 J.ZBT的游戏

    问题描述 第14届中北大学程序设计竞赛来了,集训队新买了一大堆气球,气球一共有K种颜色(1<=K<=256),气球的颜色从1-K编号. ZBT童心未泯,他发明了一种摆放气球的游戏,规则如下 ...

  5. sdut 2153 Clockwise (2010年山东省第一届ACM大学生程序设计竞赛)

    题目大意: n个点,第i个点和第i+1个点可以构成向量,问最少删除多少个点可以让构成的向量顺时针旋转或者逆时针旋转. 分析: dp很好想,dp[j][i]表示以向量ji(第j个点到第i个点构成的向量) ...

  6. sdut 2159 Ivan comes again!(2010年山东省第一届ACM大学生程序设计竞赛) 线段树+离散

    先看看上一个题: 题目大意是: 矩阵中有N个被标记的元素,然后针对每一个被标记的元素e(x,y),你要在所有被标记的元素中找到一个元素E(X,Y),使得X>x并且Y>y,如果存在多个满足条 ...

  7. 2010年山东省第一届ACM大学生程序设计竞赛 Balloons (BFS)

    题意 : 找联通块的个数,Saya定义两个相连是 |xa-xb| + |ya-yb| ≤ 1 ,但是Kudo定义的相连是 |xa-xb|≤1 并且 |ya-yb|≤1.输出按照两种方式数的联通块的各数 ...

  8. Hello World! 2010年山东省第一届ACM大学生程序设计竞赛

    Hello World! Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that Ivan gives Saya three problem ...

  9. Phone Number 2010年山东省第一届ACM大学生程序设计竞赛

    Phone Number Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that if a phone number A is anothe ...

随机推荐

  1. 了解javascript中的事件(一)

    本人目录如下: 零.寒暄 一.事件概念 二.事件流 三.事件处理程序 四.总结 零.寒暄 由于刚入职,近期事情繁多,今天好不容易中期答辩完事,晚上有一些时间,来给大家分享一篇博文. 这段时间每天写js ...

  2. extjs4与ckeditor、ckfinder整合

    <script type="text/javascript"src="<?php echo Yii::app()->request->baseUr ...

  3. [geeksforgeeks] Count the number of occurrences in a sorted array

    Count the number of occurrences in a sorted array Given a sorted array arr[] and a number x, write a ...

  4. UML部署图(转载)

    概述: 部署图用于可视化的软件组件部署的系统中的物理组件的拓扑结构. 因此,部署图是用来描述一个系统的静态部署视图.部署图由节点和它们之间的关系. 目的: 部署名称本身描述的原理图的目的.部署图用于描 ...

  5. SQL中自定义拆分为新表的函数

    /*按照符号分割字符串*/ create function [dbo].[m_split](@c varchar(2000),@split varchar(2)) returns @t table(c ...

  6. datepicker,结束时间必须大于开始时间

    $('#js-start-time').datepicker({ dateFormat:'yy-mm-dd', onSelect: function( startDate ) { var $start ...

  7. PHP 使用 Redis

    PHP 使用 Redis 安装 开始在 PHP 中使用 Redis 前, 我们需要确保已经安装了 redis 服务及 PHP redis 驱动,且你的机器上能正常使用 PHP. 接下来让我们安装 PH ...

  8. CentOS用yum安装X Window

    安装X图形界面系统 yum list 列出所有可安装的软件包 可以通过 yum grouplist 来查看可能批量安装哪些列表 先装X windows #yum groupinstall 'X Win ...

  9. C# WinForm窗口最小化到系统托盘

    * C# WinForm窗口最小化到系统托盘http://hi.baidu.com/kfxtgtqyapouyze/item/8ccfdcd5a174a7312a35c7c3 主要功能:(1).程序启 ...

  10. POJ 3177 Redundant Paths(Tarjan)

    题目链接 题意 : 一个无向连通图,最少添加几条边使其成为一个边连通分量 . 思路 :先用Tarjan缩点,缩点之后的图一定是一棵树,边连通度为1.然后找到所有叶子节点,即度数为1的节点的个数leaf ...