Hello, Codeforces!
We are happy to announce that in partnership with Codeforces to promote Kotlin programming language we are launching a series of "Kotlin Heroes" programming contests.
Kotlin programming language was introduced by JetBrains in 2011 and reached its first stable version 1.0 in 2016. The current language version is 1.3.31. The language is focused on solving the needs of application developers in various domains. Kotlin is a statically typed language that is designed for writing concise code, with less ceremony and more substance in it, and to scale from applications of just a few lines long to multi-million-lines projects.
While not being specifically designed for competitive programming, it incidentally fits well in this domain, reducing the typical amount boilerplate that a programmer needs to write and read while working with the code almost to the level offered by dynamically-typed scripting languages, while having tooling and performance of a statically-typed language.
The first "Kotlin Heroes" competition will be hosted at Codeforces platform on May/28/2019 17:35 (Moscow time). The contest will last 2 hours 30 minutes and will feature a set of problems from simple ones, designed to be solvable by anyone, to hard ones, to make it interesting for seasoned competitive programmers. Top three winners will get prizes of $512, $256, and $128 respectively, top 50 will win a Kotlin Heroes t-shirt and an exclusive Kotlin badge, competitors solving at least one problem will enter into a draw for one of 50 Kotlin Heroes t-shirts.
The round is held in accordance with slightly modified ICPC rules:
- The round is unrated.
- The contest will have 6-10 problems of various levels of complexity.
- You are only allowed to use Kotlin to solve these problems.
- Participants are ranked according to the number of correctly solved problems.
- Ties are resolved based on the lowest total penalty time for all problems, which is computed as follows. For each solved problem, a penalty is set to the submission time of that problem (the time since the start of the contest). An extra penalty of 10 minutes is added for each failed submission on solved problems (i.e., if you never solve the problem, you will not be penalized for trying that problem).
Registration is already open and available via the link. It will be available until the end of the round.
To help you get familiar with Kotlin we have prepared a tutorial on competitive programming in Kotlin and a practice round, where you can try to solve a few simple problems in Kotlin. All solutions are open, it means that you can look at a solution even if you haven't solved a problem yet. The practice round is available by the link.
We wish you luck and hope you enjoy Kotlin.
UPD 1: Many thanks to the testers elizarov, Benq, cdkrot, nhho, ksun48. Also KAN helped a lot with suggestions to the problems. And to all the participants warm greetings from authors MikeMirzayanov, vovuh, adedalic and pashka — they invented and prepared the problems for you!
Hmmm,a contest after a long time!
Did you not read that it's unrated?
Thanks, edited
It is not a hack. It is implemented to simplify Kotlin learning for Java developers. I also mention it in the official tutorial that you are quite welcome to read: https://kotlinlang.org/docs/tutorials/competitive-programming.html
In contest Java user will have benefits :(
Come to think about the benefit Kotlin users will have! :)
Btw, you are also welcome to join the Slack channel for discussion. Use http://slack.kotl.in to get an invite and join #codeforces channel. That would be the best place to ask questions about Kotin's use at Codeforces.
Would even use it as a main language immediately if creating a n-matrix is easier in Kotlin :'( .
That's coming in the near future, but voting for it would still help: https://youtrack.jetbrains.com/issue/KT-26577
I regulary use following function:
Use it like:
Why would you define it yourself? There is a Array function in the standard library that does the same:
It seems that all solutions are closed. Or am I wrong? I tried to open solution of problem A and couldn't do it.
Fixed. Open now.
What about Kotlin input\output speed? What tools should be used to do it fast?
I'd like to see the comparison of the Kotlin performance (with these wow-features) vs. other languages. Syntactic sugar is good for developing, but often causes TLE on contest tasks. As I experienced, even a simple using of streams in Java may just kill your solution.
You are welcome to read tutorial. I've explicitly covered input/output there. https://kotlinlang.org/docs/tutorials/competitive-programming.html I'd be happy if you do measurement and share them here, too.
You can code literally in Java, with some syntax exceptions like
int[]
->IntArray
.For IO, use
BufferedReader
,StringTokenizer
andPrintWriter
.You can, but idiomatice Kotlin code really looks nicer and requires less code to write. I would recommend to read tutorial on that: https://kotlinlang.org/docs/tutorials/competitive-programming.html
Hey, JetBrains, ever thought of adding CP-algorithms classes to the language itself? Like almost copy-and-paste from there.
That would cause a nice butthurt from the community of competitive programmers.
I think Kotlin is a language for industry, not for programming contests :) It would be nice to maintain a succinct standard library ;)
Most of them are extremely domain-specific. Kotlin is a general-purpose application development language, so the goal of Kotlin standard library is provide a set of basic primitive and algos for a wide range of uses and also ensure that they are not single-purpose but composable. However, one of the reasons to host these Kotlin Heros series of contests on Codeforces is to gather feedback from sports programming community. We do hope that some things that are useful here might be useful elsewhere, too.
Rated or Unrated?
Unrated
I've heard of the language, but this was a good opportunity to give it an actual chance. I actually really love it so far! I've only done 1 problem, but writing functional code is so much funner than writing normal code. Plus, you've gotta love functions like joinToString... every time I print something out in java I need an edge case at the start or end so there isn't extra whitespace. 10/10, it's like python in java
Speaking of JetBrains contests, what was the answer to the question:
Last year, a renowned painter's monument in London had three items taken out for safety. What was the sharpest one?
Razor
See this: Smoking pipe, razor and revolver removed from Van Gogh sculpture in London's Brixton
any useful website where i can get all syntax related info like a cheatsheet?
Basic Syntax is a good place to start from.
Thanks for the post, it's great to see Kotlin in competitive programming!
I have recently taken a look to Kotlin after hearing from few folks. Watched a bit of coursera course on Kotlin, then talked to Jetbrains people on Devox UK 2 weeks ago, and attended a session in the conference on its advanced features. As a Java Engineer, I find it "nice Java" with built-in lombok :) and I think it has great future with its first class support for Android, upcoming iOS development with Kotlin, running on JVM, Kotlin native, compiles to Javascript and so on.
About a week or so ago, I decided to give it a go and start my first program in Kotlin and thought solving some problems in codeforces offline might be a good idea. And I solved some problems both in Java and Kotlin to see the difference on performance, memory and code length. In terms of code length, it's much much shorter than Java like 19-20 lines of code for a graph problem which is great! In regards to performance, it was less performant than Java, maybe I'm using my own readers/writers and primitives with Java, but with Kotlin more like functional programming. Not sure how would Java Stream API compare to it, I normally avoid them in contests. Below few examples of solutions to the same problems in Java and Kotlin:
I think Kotlin's extension methods can be very helpful in competitive programming.
I tried switching to Kotlin for 90 days recently. I've noticed that my productivity has improved as well as my motivation and concentration levels. I also now feel more confident around programmers. I'm convinced that everyone should try it.
Please make program language that suits to CP.
Why I need additional functions again ?
Why a language specifically targeted to CP shall exist? Maintaining language and tools around it is a lot of effort that is worth doing only for big numbers of users. Kotlin is a pragramtic language for application developers so it would be strange if it had functions specifically for reading CP-style input which you would not find outside of CP.
Probably, it is the task for a platform to provide the some IO code/module. This was one of the ideas I liked in topcoder (and, probably, in HackerRank). Though the implementation in former case was not very successful.
rng_58 btw please update kotlin in atcoder
Why downvotes? Today I tried kotlin in beginner contest got 7 unsuccessful submissions because of language version
The description should say "You are only allowed to use Kotlin", not "You are allowed to only use Kotlin". As it is now, it is implying that we might be able to use any language we want, and also that we will not be forced to use languages other than Kotlin.
Maybe... that IS what they mean. You're just ASSUMING that you aren't allowed to use other languages.
It is what it is. Only Kotlin allowed to use you are. :)
Actually, it doesn't. It means you are only allowed to use Kotlin.
I don't think it matters or is important but yes it certainly does.
"You are allowed to only use Kotlin" means that you have a right to use Kotlin, but doesn't restrict other programming languages.
Nvm, I thought he was complaining about the first phrase, not the second one. Reading while asleep 101. ¯\_(ツ)_/¯
Not fond of this kind of discussion (being a mathematician on linguistics), but I do think the first comment has the point.
Consider the following sentences (equivalent, apart from the definition of the word vegan).
In the same way:
Everybody but please don't do this offline, it embarrasses others.
Thanks, fixed.
why the contest is unrated??
Because you have to use Kotlin, so a lot of the contest tests your familiarity with Kotlin, rather than your ability to solve problems in the language of your choice. How well you perform in this contest is not a good indicator of how well you will perform in a usual CF contest.
Top three winners will get prizes of 512, 256, and 128 dollars, then participant in $$$i$$$-th place would get $$$2^{10-i}$$$ dollars?
If so, I would get 0.006103515625 cents.
Traditionally, we publish algorithm of selecting random winners before the round.
The seed will be the total penalty best participants of this contest, the parameter length will be the total number of participants solved at least one problem minus 50.
[EDIT] — Nvm, I was getting seg fault because of alias set on my system.
According to this seed(398) and len(824) value, these are the winners
77 , 133 , 135 , 145 , 162 , 165 , 175 , 181 , 197 , 200 , 211 , 212 , 221 , 234 , 236 , 262 , 270 , 300 , 344 , 347 , 348 , 360 , 378 , 380 , 384 , 398 , 458 , 481 , 494 , 537 , 554 , 578 , 580 , 581 , 583 , 639 , 646 , 666 , 676 , 690 , 703 , 721 , 745 , 760 , 774 , 783 , 787 , 811 , 835 , 854
Is this the reel results?
Yes you can see the comment by Mike below
the total penalty best participant s?
How are ties broken?
very curious too
I'm glad to announce the winners (tie are resolved by last accepted submission time as in ICPC):
I am 580 place too :(
I missed a tshirt by 5 secs :(
I'm stoked. I think it's the first time I win something lol.
wow!
When will we receiving our t-shirts?
Hello! T-shirts will be manufactured and shipped when all the winners fill in the full relevant information (for that they have one more day).
Do you have any news about the T-shirt?
T-shirts are produced now. But we will try our best that all the winners get their prizes as soon as possible.
Any updates??
I got my T-shirt but without exclusive badge. Do I get it with another parcel?
Do you know where is the T-shirt being shipped from?
Did you get a tracking number for yours CrafterKolyan?
Yes, from Saratov. I did get my tracking number. I've already received a parcel but without Kotlin Badge.
Hmmm. I didn't get a tracking number yet. But I am in the US, I looked up what it costs to ship from US to Russia figuring it'll be about the same the other way, yeah its like $70, worth more than the T-Shirt about 7x.
But I did find out its illegal, among other things, to mail things from here to Russia, I kid you not, containing "Information about the Earth’s interior."
Apparently my government really doesn't want you guys to know there be elves down there.
Canada, and got the tracking number a few days ago.
Hmm, I searched my Inbox and Spam and couldn't find it. It came from codeforces.com?
You Deemo and CrafterKolyan are in top 50, I am in the raffle bottom 50, maybe they send those out later.
Maybe Una_Shem knows.
Thanks.
No problem. They send you a message on Codeforces. It's hard to miss.
Hello! Sorry for the late reply. Yes, badges will be sent later.
Hi, I was in the raffle bottom 50 who won a T-shirt, but I didn't get a tracking number or a t-shirt yet, have they all been sent out yet? I made sure my address was filled out in CF the day I won.
I have received my t-shirt.
That's good news! Hope to see you taking part in the next contests! :)
It appears that my package has gotten stuck somewhere in the process (according to my tracking link, the last update was about 2 weeks ago that it passed customs in the US, but I have heard no further news nor received anything locally to indicate it has been delivered). Is this expected?
I think, you wouldn't be.
I needed another minute for F 54766100
I'm 54th.
Kill me
I had to leave contest 30 minute early and was almost done with F... I'm 51st. Kill me
What's the reason for TL 45 in F? My only guess is that it is because LongArray.sort() works in $$$O(n^2)$$$ just like in Java. But why include such tests in Kotlin-only contest?
I doubt it; my
Array<Pair<Int, Int>>.sortWith(compareBy(...))
worked fine in B.Well, in Java arrays of objects are sorted in $$$O(n\log(n))$$$ with merge sort and only arrays of primitive type are sorted with bad quick sort.
Oof
Your guess is correct. Same for me.
TL 45 54766357
AC 54766461
I used
.sorted()
and it worked fine. Is there any Kotlin sort function that is $$$O(n^2)$$$? I thought Kotlin sorts are fine, but I don't have proof.It would be nice if they put in reference time complexity and which algorithm is used like in C++ reference.
link
Can someone explain this?
I haven't solved even a single question, in fact I don't even know Kotlin programming language.
If I go to "My submissions" section of the contest, there are no submissions (which makes it clear that my account wasn't hacked).
Is it a bug? Am I the only person who is facing it?
The problems are all reused from old contests, so if you've solved it in the old contest, the it still counts as "solved" (just like Div 1 and Div 2 sharing problems).
Understood, thanks for the clarification.
I used the problems from other rounds to make the practice contest, you solved them previously.
Yes I didn't realize that, thanks.
Those problems are taken from other contests you may have solved previously, if you open a task you may recognise it.
Yes, I just checked it and realized I have solved em early. Thanks.
I spent a good 2 hours understanding problem E, only to realize the compartments having the door are closed, not opened.
There goes the T-shirt :(
Same here, lol.
I have been confused about it for about 15 minutes, and barely got it by asking the question.
Why is system testing of practice round still not over?
MikeMirzayanov elizarov It would be great if we could now make submissions for the contest in other programming languages to compare performance against Kotlin.
Is there a way to get a tracking number for the shirt delivery?
You will receive the tracking number automatically within several days after sending.
Cool. Thanks!
hey elizarov, the only concern I feel right now with kotlin for CP is the huge runtime. I would love to read about the reason behind it, I felt it shouldn't be much different from JAVA yet we can see a huge difference between them.
I understand in CP the time will be adjusted based on the language but a general curiosity. Asgar has posted his solution in both java and kotlin and we can see a difference of more than 600ms.
java & kotlin
java & kotlin
I have observed the same while practising problems in kotlin on other platforms too.
Just want to know the theory behind it. And are there any plans in tackling them, and also will it effect products in real life which may require heavy computations.
These submissions have completely different code so it's no surprise they take different time to run. As an exercise, you can convert Java code to Kotlin to see that it gets the same runtime and vice-versa (this conversion can even be done mostly automatically by IDEA!), and you can also convert Kotlin code Java and it will, again, have the same runtime.
neo11235