posts - 74,  comments - 33,  trackbacks - 0
贪心的思想是每经过5分钟如果有可以选的课,那么就选所有可以选的课中最早结束的那一门课,然后t+=10(5minutes)!可是如果当前时间刚好没有选课(也就是没有选到课,我们不必等5minutes),那么按照题目的意思我们可以对t+=2(1minutes)。这样有错吗?我把你写的code按上面的想法改了,可是不对??
请神牛赐教!
QQ:707089795
re: itoa的两种实现[未登录] Knight 2010-10-29 15:17
你的itoa有个问题:
你传进来的参数char *string, 它的空间大小用户无法知道
re: [ZZ]后缀数组[未登录] Knight 2010-07-30 09:26
@爱上对方
请你仔细阅读标题
【ZZ】转载。。懂
用_strdup把std::string 转成char* 后, 还必须自行去free char*数据,否则会有内存泄漏
re: poj 3648 Wedding[未登录] Knight 2009-08-25 21:37
@inowfordream
有个条件说夫妻不能在一边吧 。。。。这题很久了。。
re: 后天省赛了 Knight 2009-05-24 23:30
结束了。。。。。
re: Network of Schools Knight 2009-05-14 07:24
感谢zju的HH神牛,谢谢 HH神牛的数据2个点 a->b
2
2 0
0
对于in==1&&out==1但是scc==2


re: 最优比例生成树[未登录] Knight 2009-01-20 08:54
@菠萝东西
代码我发到你邮箱了。
re: Stars[未登录] Knight 2009-01-12 10:01
#include<stdio.h>
#define SIZE1 32000
#define SIZE2 15000
int c[SIZE1],a[SIZE1],out[SIZE2],n;
int lowbit(int k)
{
return k&(-k);
}
int sum(int k)
{
int ret=0;
while(k>0)
{
ret+=c[k];
k-=lowbit(k);
}
return ret;
}
void change(int pos,int delt)
{
while(pos<=SIZE1)
{
c[pos]+=delt;
pos+=lowbit(pos);
}
}
void init()
{
int i;
int x,y;
for(i=0;i<n;i++)
{
scanf("%d%d",&x,&y);
x++;
out[sum(x-1)+a[x]]++;
change(x,1);
a[x]++;
}
}
int main()
{
int i;
scanf("%d",&n);
init();
for(i=0;i<n;i++)
printf("%d\n",out[i]);
}
pip来了,但是他说他也不会他是线段树过的。。。。。
线段树。。。。。代码不是我的。。。网上的。。。。不过不错。。。题目有个条件就是按y升序给出数据。。。。所以可以用树状数组,其实可以排序在用的。。。。。继续物理。。。。关机。。。
re: The Troublesome Frog Knight 2009-01-08 22:32
我晕,一个晚上居然没调出来。。。。。
读题还少了条件。。。。。
现在可好了还是超时的东西。。。。
re: POJ 2967 Triangles Knight 2008-12-25 12:37
思路没错,因为写的时候
有了min1+min2<=MAX存在了溢出问题。。。。所以WA了
改了之后排名第四516msAC
re: poj 2111 Millenium Leapcow Knight 2008-12-24 12:43
鱿鱼大牛的思路
从n*n开始搜索到1结束DP更新路径
排名20 3160K 157MS C++ 1228B
还行经典代码如下:
for(i=M;i>=1;i--)
{
for(j=0;j<8;j++)
{
int x=num[i].x+dir[j][0];
int y=num[i].y+dir[j][1];
if(OK(x,y,i))
{
if(num[i].max+1>num[map[x][y]].max)
{
num[map[x][y]].max=num[i].max+1;
pre[map[x][y]]=i;
}
else if(num[i].max+1==num[map[x][y]].max&&i<pre[map[x][y]])
pre[map[x][y]]=i;
}
}
if(MAX<=num[i].max)
{
MAX=num[i].max;
sign=i;
}
}
re: poj 2111 Millenium Leapcow Knight 2008-12-23 23:22
如果你能接受这个
3160K 1047MS C++ 1547B
真的很烦,居然1047ms一般都是200ms左右我居然这么多,晕
思路还是最长上升子序列
不过更新路径的函数代码如下
int cmp(int a,int b)
{
if(pre[a]==a)
{
if(a>b)return 1;
else if(a==b)return 0;
else return -1;
}
else
{
int t=cmp(pre[a],pre[b]);
if(t==0)
{
if(a>b)return 1;
else if(a==b)return 0;
else return -1;
}
else return t;
}
}
********************************
即如果路径长度相同的话,就执行cmp从而判断字典序!更新字典序!很浪费时间!
********************************
re: HOJ 1797 -- Red and Black Knight 2008-11-23 12:58
有意讨论电脑知识及 算法和 语言类网络类 知识的人 可以入群 75126876
re: HOJ 1797 -- Red and Black Knight 2008-11-21 19:24
@huhupao
眼拙没看出来。。。
re: HOJ 1797 -- Red and Black Knight 2008-11-19 23:53
请问这个stack的实现的bfs效率怎么样啊。。。
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(8)

随笔档案

文章档案

Friends

OJ

搜索

  •  

最新评论

阅读排行榜

评论排行榜