Redian新闻
>
想起了很傻很天真 (转载)
avatar
想起了很傻很天真 (转载)# Joke - 肚皮舞运动
p*2
1
擦,真心跪了,我找了HR要了test的结果,各位大牛看看吧,貌似我题目理解错了?
extreme_single_letter
single letter
0.25 s. WRONG ANSWER got 0 expected 1
extreme_a5
a*5
0.24 s. WRONG ANSWER got 0 expected 5
medium1
ab*1000
0.31 s. WRONG ANSWER got 1 expected 1000
好可惜。。这个教训好深刻
O(n)的解法。
avatar
a*a
2
想买张里程票,还差2000miles。怎么最快捷、经济的earn到UA的里程?
我看在FTD上是 花50刀给1250miles。是不是给自己订两束花?
avatar
b*d
3
【 以下文字转载自 Military 讨论区 】
发信人: ADAPTABLE007 (ADAPTABLE007), 信区: Military
标 题: 想起了很傻很天真
发信站: BBS 未名空间站 (Sun Nov 11 01:30:25 2012, 美东)
这是小编捉弄人呢吧。
avatar
l*i
4
二爷,我告诉你吧,这个题不是之前帖子里那个意思!我今早做了,一激动提交了,结
果后悔了,忘了考虑worst case的复杂度。估计要跪了。
avatar
B*y
5
订吧,对自己好点。。。

【在 a***a 的大作中提到】
: 想买张里程票,还差2000miles。怎么最快捷、经济的earn到UA的里程?
: 我看在FTD上是 花50刀给1250miles。是不是给自己订两束花?

avatar
r*s
6
哈哈,天真
avatar
l*i
7
正确题意:
按照string长度N,一共有N种shift.当i shift (0=叫做cyclic automorphism。要求return一共有多少cyclic automorphism。
byebye 0 shift counter = 1
yebyeb 1 shift
ebyeby 2 shift
byebye 3 shift counter = 2
yebyeb 4 shift
ebyeby 5 shift
return counter;
可以用KMP去比较(s+s,s)。结果我早上傻了,用KMP把所有的s在s+s里找了一遍。。
。。提交了才发现,我跪了。其实只要找到第一个出现的重复出现的S的位置就够了。
比如byebye,第一次重复在位置3,用s的length去除第一次位置,就是结果。
所有a*5,其实是aaaaa,应该结果是5!
avatar
b*e
8
还不如去二手买,还花不了这么多

【在 a***a 的大作中提到】
: 想买张里程票,还差2000miles。怎么最快捷、经济的earn到UA的里程?
: 我看在FTD上是 花50刀给1250miles。是不是给自己订两束花?

avatar
w*h
9
党真的很好很纯洁。。。这样才顺口。。。

【在 b*****d 的大作中提到】
: 【 以下文字转载自 Military 讨论区 】
: 发信人: ADAPTABLE007 (ADAPTABLE007), 信区: Military
: 标 题: 想起了很傻很天真
: 发信站: BBS 未名空间站 (Sun Nov 11 01:30:25 2012, 美东)
: 这是小编捉弄人呢吧。

avatar
p*2
10

对。我这个帖子的题意就是这个意思。原帖的问题是错的。LZ纠正了,可是没人看了。

【在 l****i 的大作中提到】
: 正确题意:
: 按照string长度N,一共有N种shift.当i shift (0=: 叫做cyclic automorphism。要求return一共有多少cyclic automorphism。
: byebye 0 shift counter = 1
: yebyeb 1 shift
: ebyeby 2 shift
: byebye 3 shift counter = 2
: yebyeb 4 shift
: ebyeby 5 shift
: return counter;

avatar
B*y
11
但二手板给你鲜花么?

【在 b*****e 的大作中提到】
: 还不如去二手买,还花不了这么多
avatar
p*2
12

看来还是得搞KMP呀。我这个周末得好好学学。

【在 l****i 的大作中提到】
: 正确题意:
: 按照string长度N,一共有N种shift.当i shift (0=: 叫做cyclic automorphism。要求return一共有多少cyclic automorphism。
: byebye 0 shift counter = 1
: yebyeb 1 shift
: ebyeby 2 shift
: byebye 3 shift counter = 2
: yebyeb 4 shift
: ebyeby 5 shift
: return counter;

avatar
b*k
13
您是来卖花的吧……

【在 B******y 的大作中提到】
: 但二手板给你鲜花么?
avatar
c*t
14
算出周期,length再一除,不也一样?
如何算周期,看我那个另外一个帖子的最后回帖。
KMP不是 O(n), 把所有length都试一遍,不还是O(n^2)?

【在 p*****2 的大作中提到】
: 擦,真心跪了,我找了HR要了test的结果,各位大牛看看吧,貌似我题目理解错了?
: extreme_single_letter
: single letter
: 0.25 s. WRONG ANSWER got 0 expected 1
: extreme_a5
: a*5
: 0.24 s. WRONG ANSWER got 0 expected 5
: medium1
: ab*1000
: 0.31 s. WRONG ANSWER got 1 expected 1000

avatar
a*a
15
谢谢提醒,突然想起来是不是可以把freedom挣得点数转过来一些?

【在 b*****e 的大作中提到】
: 还不如去二手买,还花不了这么多
avatar
l*i
16
在S1里找到S2的第一次出现,用KMP是O(n)

【在 c********t 的大作中提到】
: 算出周期,length再一除,不也一样?
: 如何算周期,看我那个另外一个帖子的最后回帖。
: KMP不是 O(n), 把所有length都试一遍,不还是O(n^2)?

avatar
f*8
17
花我一般是去附近公园摘得.大概有0.5mile吧
avatar
p*2
18

你那个帖子的回帖不是O(n)吧?KMP为什么不是O(n)?

【在 c********t 的大作中提到】
: 算出周期,length再一除,不也一样?
: 如何算周期,看我那个另外一个帖子的最后回帖。
: KMP不是 O(n), 把所有length都试一遍,不还是O(n^2)?

avatar
D*s
19
哈哈,这个点评犀利啊

【在 b***k 的大作中提到】
: 您是来卖花的吧……
avatar
c*t
20
KMP搜s是O(n), 问题是这道题,你难道不要试 从length 1到n/2的所有substring吗?

【在 p*****2 的大作中提到】
:
: 你那个帖子的回帖不是O(n)吧?KMP为什么不是O(n)?

avatar
D*s
21
你如果有CSP或者ink或者更高等级的卡才可以把freedom的点数转到UA

【在 a***a 的大作中提到】
: 谢谢提醒,突然想起来是不是可以把freedom挣得点数转过来一些?
avatar
l*i
22
用KMP其实也是找到你所说的周期,然后用length去除。

【在 c********t 的大作中提到】
: KMP搜s是O(n), 问题是这道题,你难道不要试 从length 1到n/2的所有substring吗?
avatar
a*y
23
这阵子UAdining 除了三倍积分外再 送1500点。然后就是去他家的shopping mall 找那
些八倍十倍点数送的。。。
avatar
c*t
24
对啊,所以还是O(n^2), 因为你要从1试到n/2看有没有周期啊,难道还有别的trick?

【在 l****i 的大作中提到】
: 用KMP其实也是找到你所说的周期,然后用length去除。
avatar
l*i
26
为什么O(n^2)?KMP去找,是O(n)啊。

【在 c********t 的大作中提到】
: 对啊,所以还是O(n^2), 因为你要从1试到n/2看有没有周期啊,难道还有别的trick?
avatar
g*u
27
真的假的?真的你好意思说?

【在 f******8 的大作中提到】
: 花我一般是去附近公园摘得.大概有0.5mile吧
avatar
e*i
28
原帖楼主表示第一次做这种Online test 不看清题目狠丢人,教训狠深刻,吃亏狠深
avatar
l*i
30
move on,我早上做的,也跪了。

【在 e******i 的大作中提到】
: 原帖楼主表示第一次做这种Online test 不看清题目狠丢人,教训狠深刻,吃亏狠深
avatar
m*3
31

请问哪里有写join就可以拿1500 points的?

【在 f*********9 的大作中提到】
: http://mpdining.rewardsnetwork.com/
: join to get 1500 points, then spend a couple hundred to eat...

avatar
c*t
32
我也有点懵了。
给你一个string abaaabaa
你拿什么去kmp找周期?难道不是要拿a, ab, aba, abaa去找吗?O(n*n)啊

【在 l****i 的大作中提到】
: 为什么O(n^2)?KMP去找,是O(n)啊。
avatar
i*d
33

话说这个可以参加多个program的吗,我看还有aa和delta的,用一张卡不能同时拿到这
几个bonus吧?

【在 f*********9 的大作中提到】
: http://mpdining.rewardsnetwork.com/
: join to get 1500 points, then spend a couple hundred to eat...

avatar
l*i
34
我的意思是,比如这题输入是"abab"
KMP("abababab","abab"),从index位置1开始找,可以找到index位置2,发现找到了。
这样KMP找到index是2.这个2就是你所说的周期吧。

【在 c********t 的大作中提到】
: 我也有点懵了。
: 给你一个string abaaabaa
: 你拿什么去kmp找周期?难道不是要拿a, ab, aba, abaa去找吗?O(n*n)啊

avatar
v*e
35
刷两千帮神医买点啥吧,至少自己不损失啊。买花成本太高了
avatar
c*t
36
哦,对,明白了,多谢。

【在 l****i 的大作中提到】
: 我的意思是,比如这题输入是"abab"
: KMP("abababab","abab"),从index位置1开始找,可以找到index位置2,发现找到了。
: 这样KMP找到index是2.这个2就是你所说的周期吧。

avatar
f*f
37

23333拍桌笑!

【在 B******y 的大作中提到】
: 但二手板给你鲜花么?
avatar
p*e
38
这个问题,简化一下就是求一个矩阵的秩
矩阵是字符串的数值
avatar
p*2
39
找到这题的出处了。还没看太懂。
A typical problem seen quite often is: given a string find its shortest
substring, such that the concatenation of one or more copies of it results
in the original string. Again the problem can be reduced to the properties
of the failure function. Let's consider the string
A B A B A B
and all its proper suffix/prefixes in descending order:
1 A B A B
2 A B
3 /the empty string/
Every such suffix/prefix uniquely defines a string, which after being "
inserted" in front of the given suffix/prefix gives the initial string. In
our case:
1 A B
2 A B A B
3 A B A B A B
Every such "augmenting" string is a potential "candidate" for a string, the
concatenation of several copies of which results in the initial string. This
follows from the fact that it is not only a prefix of the initial string
but also a prefix of the suffix/prefix it "augments". But that means that
now the suffix/prefix contains at least two copies of the "augmenting"
string as a prefix (since it's also a prefix of the initial string) and so
on. Of course if the suffix/prefix under question is long enough. In other
words, the length of a successful "candidate" must divide with no remainder
the length of the initial string.
So all we have to do in order to solve the given problem is to iterate
through all proper suffixes/prefixes of the initial string in descending
order. This is just what the "failure function" is designed for. We iterate
until we find an "augmenting" string of the desired length (its length
divides with no remainder the length of the initial string) or get to the
empty string, in which case the "augmenting" string that meets the above
requirement will be the initial string itself.
avatar
p*2
40

大牛。我刚才做了一个KMP,没发现比BF快呀。

【在 l****i 的大作中提到】
: 正确题意:
: 按照string长度N,一共有N种shift.当i shift (0=: 叫做cyclic automorphism。要求return一共有多少cyclic automorphism。
: byebye 0 shift counter = 1
: yebyeb 1 shift
: ebyeby 2 shift
: byebye 3 shift counter = 2
: yebyeb 4 shift
: ebyeby 5 shift
: return counter;

avatar
l*8
41
storm8 是自己去他家网上投,然后就会收到online test的链接吗? 还是需要人refer?

【在 p*****2 的大作中提到】
: 擦,真心跪了,我找了HR要了test的结果,各位大牛看看吧,貌似我题目理解错了?
: extreme_single_letter
: single letter
: 0.25 s. WRONG ANSWER got 0 expected 1
: extreme_a5
: a*5
: 0.24 s. WRONG ANSWER got 0 expected 5
: medium1
: ab*1000
: 0.31 s. WRONG ANSWER got 1 expected 1000

avatar
p*2
42

refer?
我也不知道呀。估计都可以吧。

【在 l*********8 的大作中提到】
: storm8 是自己去他家网上投,然后就会收到online test的链接吗? 还是需要人refer?
avatar
p*2
47
算了,自己动手丰衣足食,写了一个
def maxsub(s:String):Int={
val n=s.length
val dp=new Array[Int](n)

for(ivar j=i
while(j>0 && s(i)!=s(dp(j-1))) j=dp(j-1)
dp(i)=if(j>0) dp(j-1)+1 else 0
}

var j=dp(n-1)
while(n%(n-j)!=0) j=dp(j-1)
n/(n-j)
}
avatar
p*2
48
这题没人感兴趣了吗?
avatar
j*e
49
2爷都要跪了,我等草码,不要碎了。。。
avatar
p*2
50

原帖是我转的。不过这题我碰到也完了,因为从来没写过KMP。

【在 j*******e 的大作中提到】
: 2爷都要跪了,我等草码,不要碎了。。。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。