Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

### MikeMirzayanov's blog

By MikeMirzayanov, history, 4 years ago, translation, ,

The language of the round is Kotlin. Kotlin is a statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code. Its primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia (the name comes from the Kotlin Island, near St. Petersburg).

Here is an example of the simplest program on Kotlin to print sum of two numbers:

fun main(args: Array<String>) {
val (x, y) = readLine()!!.split(' ').map(String::toInt)
println(x + y)
}


The password from the archives with IDEA (IDE supporting Kotlin out of the box): c8bf9dd9b91ad9ff Links to IDEA are below or you can download it from the official website

Good luck!

====

UPD: You can predownload development pack (sorry, 300MB). In fact, you can take part without it — the Custom Invocation tab will be available during the contest. Also we will publish more compact tools 30 minutes before the start.

OS
Linux http://s.codeforces.com/files/683-linux.7z
Windows http://s.codeforces.com/files/683-windows.7z
Mac OS http://s.codeforces.com/files/683-macos.7z

All archives are encrypted. The password will be announced 30 minutes before the contest.

========

Surprise Language Round #8 will start on June 16, 16:00 (UTC). It will be unusual entertaining contest. Solutions on the only programming language will be allowed.

Thus, it is expected that during the round, participants can get acquainted with the language and solve a few simple problems. The language will be announced 30 minutes before the start of the round. At the same time (or earlier but encrypted archives) we will publish the archives with the tools to write programs in this language.

I am pleased to announce that the top 20 participants will receive an exclusive t-shirt, and another 10 random participants among those who solved at least three problems will receive an exclusive t-shirt too.

The rules of the contest are as follows:

• The contest is unrated for everybody.
• The round uses ACM ICPC rules: the standing is defined by the number of solved problems, ties are resolved based on penalty time. Initially the penalty is 0, and for each solved problem it is increased by submission time (since the start of the contest) + 20 minutes for each failed submission. The solution is considered to be correct if it passes all tests from a predefined test set; you know whether the solution is right immediately after sending it. There are no hacks.
• The round will have 8-10 problems, sorted by estimated complexity, and you have 2 hours to solve it.
• Solutions are accepted only in one language, which will be announced in 30 minutes before the contest.
• Please reread this post at the beginning of the contest: we will announce the language and add instructions to install the compiler (the contest interface will provide an option to run your solutions online as well) and links to useful manuals. Other than that, learning the language is up to the competitor. You can use any resources to solve the problems (as long as you remember that this is an individual competition); you don't have to limit yourself to the manuals provided in the post.

Good luck!

• +82

 » 4 years ago, # |   +136 First SLR I'm eligible to participate in in 5 years.9 am on a weekday in my time zone.:-(
•  » » 4 years ago, # ^ |   +1 Take the morning off?
 » 4 years ago, # |   +24 It is awesome that Surprise Language Round comes back since the previous Surprise Language Round was 21 months ago.
•  » » 4 years ago, # ^ |   +46 Unless you count VK Cup 2015 Wildcard Round 1 15 months ago and VK Cup 2016 Wildcard Round 1 2 months ago, which both used SLR format and both had parallel rounds open to everybody. Or do you feel nostalgic about the name "Surprise Language Round" itself? :-)
 » 4 years ago, # | ← Rev. 2 →   0 Hmm. After reading the Blog I should say the Round will obviously be a Fun one.This is my First SLR . And hope to participate . Thanks Mike to arrange this Round. And hope everybody to have a Good Contest.
»
4 years ago, # |
Rev. 2   -27

In fact, this contest is interesting, and I want to participant it.

#### My dream is going to get a T-Shirt. Can you pray for me?

•  » » 4 years ago, # ^ |   +7 Okey ....I Can Pray. But I really can't Prey ....
•  » » » 4 years ago, # ^ |   -18 Oh,sorry. but I can beat you.
•  » » 4 years ago, # ^ | ← Rev. 2 →   +26 A moment of silence for our dear departed friend, English.
•  » » 4 years ago, # ^ |   0 Spray the Helix Fossile!
 » 4 years ago, # |   0 Hi, I am new to CodeForces competitions, and this will be first one. Will the programming language be something completely new(like an unknown language)? Or will it be like a custom/madeup language?thanks pimaster314
•  » » 4 years ago, # ^ |   0 It will be an existing but esoteric programming language. You can see the languages used in previous surprise language rounds in the link below.http://codeforces.com/blog/entry/13750
 » 4 years ago, # |   +1 Tshirt! registered. :)
 » 4 years ago, # |   +6 Really excited related to this contest, it will be fun to know a completely new language. Contest Like these makes coding and codeforces interesting.
 » 4 years ago, # |   +11 Exclusive! Exclusive!. How this is exclusive?! Can we see it?
 » 4 years ago, # |   +13 Not gonna lie, I registered for the T-shirts.
•  » » 4 years ago, # ^ |   +5 Lol. I updated my Tshirt size, just in case ;-)
•  » » » 4 years ago, # ^ |   +1 LoL. Reminds me of the time when I hurried up in updating my Tshirt size after I won one. I never actually cared because I never though I'll get one ;)
•  » » » » 4 years ago, # ^ |   0 I never updated my T-shirt size on baylor site so I recieved an XL T-Shirt. I switched it with my team mate and he still doesn't know about it why did he got a XL T-shirt xD .
•  » » » » » 4 years ago, # ^ |   0 lol I did the same xD
 » 4 years ago, # | ← Rev. 2 →   -25 !!!
•  » » 4 years ago, # ^ |   +9 T-shirts
 » 4 years ago, # | ← Rev. 2 →   0 .
 » 4 years ago, # |   0 expecting that it will really surprise us..:D
 » 4 years ago, # |   +3 NO!!I haven't finished downloading it yet. Is there any way to get it faster?
 » 4 years ago, # |   +4 First link, the wikipedia one, is broken I can't click on it, only copy and paste to address bar works.
•  » » 4 years ago, # ^ |   0 just copy web-address and then go to it.
 » 4 years ago, # |   +1 which compiler should i select in custom test?
 » 4 years ago, # |   +84 Kotlin? It seems that the next SLR is going to have C++ as the only language:) Btw, it surely will be a great surprise:)
•  » » 4 years ago, # ^ |   0 +1 This is so similar to Scala :/There isn't much of a surprise.
•  » » 4 years ago, # ^ | ← Rev. 2 →   +30 +1They might be choosing Kotlin for introducing some harder task to SLR, but Kotlin is way too common (and too sane). Quite different from old SLRs by Nickolas.Well, next time you can do this for Rust, or Elixir, or whatever.
•  » » » 4 years ago, # ^ |   0 Yeah, rust sounds pretty interesting.
•  » » 4 years ago, # ^ | ← Rev. 2 →   +45 Kotlin is too common to be fair. People who are familiar with the language (or even with Java) has a clear advantage.
 » 4 years ago, # |   +9 still cant figure out how to read input >_>
•  » » 4 years ago, # ^ |   0 Me too :(
•  » » 4 years ago, # ^ |   0  val (x, y) = readLine()!!.split(' ').map(String::toInt) this can solve the first problem,but i dont know how to read a string :(
•  » » » 4 years ago, # ^ |   0 var y = readLine() 
•  » » » » 4 years ago, # ^ |   0 Why var y = readLine() and not:val y = readLine()
•  » » » » » 4 years ago, # ^ |   +1 As I understand, we can't change the value of val
•  » » » » » » 4 years ago, # ^ |   0 Thank you.
 » 4 years ago, # |   0 I am unable to compile my source code from given compiler. Any help?
•  » » 4 years ago, # ^ |   0 I guess you forget to add header files import java.util.* 
 » 4 years ago, # |   +4 I cant find any courses that tell me how to read a string or read input one by one:(
 » 4 years ago, # |   0 How to use the compiler? The IDE told me that I did not have Project SDK.
 » 4 years ago, # |   +22 Random winners of 10 t-shirts will be determined using the following code (testlib is used). The code will be executed with two parameters in the command line: number of participants with at least 3 problems and penalty of the lowest among them. #include "testlib.h" #include using namespace std; int main(int argc, char* argv[]) { registerGen(argc, argv, 1); int n = atoi(argv[1]); vector places; for (int i = 21; i <= n; i++) places.push_back(i); shuffle(places.begin(), places.end()); cout << "T-Shirt Random Winners:"; for (int i = 0; i < 10; i++) cout << " " << places[i]; cout << endl; } 
•  » » 4 years ago, # ^ |   +23 ./shirts 240 436 T-Shirt Random Winners: 95 39 152 69 26 177 217 75 193 187 That was one of the most interesting contests I've ever participated btw.
•  » » 4 years ago, # ^ | ← Rev. 2 →   +41 Many congratulations to t-shirt winners (1-20): And random winners (yes, 12 t-shirts because of ties):
•  » » » 4 years ago, # ^ |   +4 I wish I had 187th rank rather than 87th :/
•  » » » » 4 years ago, # ^ |   +3 Lel I wish I had 26 instead of my 25 :D
•  » » » 4 years ago, # ^ |   +18 Aww! Missed the T-shirt, but it's always fun doing SLRs. Wish they are held more frequently.
•  » » » 4 years ago, # ^ |   +5 MishaPrigara took 117 place, not 177. Check it please
•  » » » » 4 years ago, # ^ |   +11 Oh, I missed. Thanks, fixed. I'll ask for exta t-shirt for MishaPrigara.
•  » » » 4 years ago, # ^ |   +1 The contest was awesome Mike, Thank you.About the t-shirt, I didn't receive an email or any sort of thing. So, please email me at khaledali21345@gmail.comThanks.
•  » » 4 years ago, # ^ |   +52 This code crashes if n ≤ 30. I just hacked MikeMirzayanov!
 » 4 years ago, # |   -15 website was not able to load between the contest for few minutes, especially custom invocation page.
 » 4 years ago, # |   0 O(N lg K) was supposed to pass on G?I got TLE on #21 :/
•  » » 4 years ago, # ^ |   0 You meant H? Not sure about O(NlgK), solved it with O(N).
•  » » » 4 years ago, # ^ |   0 Yeah H, how in O(N).I used binary jumping for N lg K.
•  » » » » 4 years ago, # ^ |   0 Iterate over every student, build cycles for them — it is O(N)For every cycle get shift = K % cycle_len, for every student in cycle get his new book from (i — shift) pos in cycle (if lesser than 0 += cycle_len). It is O(N) too.
•  » » 4 years ago, # ^ | ← Rev. 2 →   0 Solved it with O(NlogK): 18526851. I'm guessing your solution is slower than mine because of large array.
•  » » » 4 years ago, # ^ |   0 Ah! I made the mistake of storing the whole precalc table :/ Should have done it on the fly.
 » 4 years ago, # |   0 Ah, placed 25, so close.
 » 4 years ago, # |   0 What is wrong with this for C?I get Runtime Error on test 17: 18529037
•  » » 4 years ago, # ^ |   +3 You should try to write simpler code.http://codeforces.com/contest/683/submission/18525180
•  » » » 4 years ago, # ^ |   0
•  » » 4 years ago, # ^ |   0
•  » » » 4 years ago, # ^ |   0 I get it that this isn't the most elegant way to do it, but I had no idea about these contains functions, still what is wrong with my code? The thing I did was mostly straightforward, dont understand why it would get RE :/
•  » » » » 4 years ago, # ^ | ← Rev. 2 →   0 java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:592) at java.lang.Integer.parseInt(Integer.java:615) at ProgramKt.main(program.kt:51) You tried to parse an empty String and it threw an exception. you should tweak how you read from input.
•  » » » » 4 years ago, # ^ |   0 Probably, there were two consecutive space between numbers. You could filter them out or just don't convert a string to int: 18525267
•  » » » » 4 years ago, # ^ |   0 To add to what others have said, you read 2 chars per number, but the numbers can range from -1000 to 1000. So even if the input does not have consecutive spaces, you can end up with stringerA starting with a space, which then causes this exception. Even if it didn’t throw this exception though, you would still get a wrong answer because you’d parse the numbers wrongly.
 » 4 years ago, # |   +18 Round is very interesting and educational.Thank you.
 » 4 years ago, # |   +28 I submitted solution for E, got TLE, so I decided to rewrite code from Java. I copy-pasted the Java code to the Kotlin file and IDEA asked: "Do you want to convert it to Kotlin code?". I clicked "Yes" and this way I got E accepted without writing a lot of Kotlin code. I wish I knew the copy-pasting rule from the beginning of the contest.
•  » » 4 years ago, # ^ |   +4 Yea, sounds cheaty from the perspective of non-Java participant :)
•  » » » 4 years ago, # ^ |   0 Definitely sounds like that. Before copy-pasting I was prepared for a long process of manual conversion from the language I knew into the language that I didn't know, so that wouldn't be so different if the source language was C++ (or any other language). The process would probably be errorprone and given the size of the SetWithCount class my initial thought was that the chances of successful conversion are slim but I had no better idea. After learning that one can convert code from Java to Kotlin I wrote solution to G in Kotlin without using Java. What's the fun of writing Java solution when it is a Kotlin contest?Anyway, the "conversion from Java to Kotlin" message was the big "WTF?!!! I was browsing the Reference manual for two hours, while I could have just written everything in Java and then convert?", so I guess the language wasn't the only surprise for me in this contest:)
 » 4 years ago, # |   +6 Heh, before this round, I've just thought, "the author seems to be Mike, so it may be a way to battle-test a new language for regular rounds".Will Kotlin be available for common rounds now as well?
 » 4 years ago, # |   +13 Did someone used "Convert from java" button of http://try.kotlinlang.org/#/Examples/ ?
 » 4 years ago, # |   +10 Do I get something wrong about J, or it is easier than I?In J you don't have to find a minimal path, so you can just blow every single wall and exit. 100k actions is more than enough for that.
 » 4 years ago, # | ← Rev. 6 →   +97 As a developer working on Kotlin at JetBrains, I'd like to present my solutions for today's problems (except H), maybe they will be of use for someone. (UPD: I did not take part in the round.) A — The Check of the Point: 18529450 B — The Teacher of Physical Education: 18529442 C — Symmetric Difference: 18529406 D — Chocolate Bar: 18529454 E — Hammer throwing: 18529466 F — Reformat the String: 18531365 G — The Fraction: 18529474 I — Loader: 18532817 J — The Hero with Bombs: 18529503
•  » » 4 years ago, # ^ |   +8 Your B solution looks great. I see that I could have just sorted the students instead of using HashMap>. Such an overkill:) I had a lot of trouble with trying to use Map.computeIfAbsent, because IDEA kept coloring it red, and I finally gave up and used temporary variables. What I wanted to do: val s: NavigableMap> = TreeMap() val z = s.computeIfAbsent(height, { k -> HashMap() }) z.put(name, z.getOrDefault(name, 0) + 1)Is there a way to use computeIfAbsent (or getOrElse or getOrPut or something else) to achieve the same effect without using temporary variables?
•  » » » 4 years ago, # ^ | ← Rev. 2 →   +3 computeIfAbsent is not available in kotlin.Map currently because it breaks variance of Map's generic type parameters. I believe this is being discussed and worked on currently (link).I don't think there's a nice way to write this without using temporary variables :) I can only suggest something like the following:  val s: NavigableMap> = TreeMap() s.getOrPut(height) { HashMap() }.let { map -> map[name] = (map[name] ?: 0) + 1 } 
•  » » 4 years ago, # ^ |   0 You don’t need the last capitalize call in F, do you?
•  » » » 4 years ago, # ^ |   0 You're right, it's not needed. I've updated the solution. Thanks!
 » 4 years ago, # |   +55 For problem I, I noticed something strange in some accepted solutions: I thought we needed to minimize the number of pushes. It seems they are printing three pushes, while the optimal solution is only one push.
•  » » 4 years ago, # ^ |   0 Can you please share the submission id?
•  » » » 4 years ago, # ^ |   0 This is mine: 18529203Seems that it minimizes answer's length :)
•  » » » » 4 years ago, # ^ |   0 Seems like the checker actually accepts any correct sequence at least one of them exists.
•  » » » 4 years ago, # ^ |   0 One such solution: 18527894
•  » » 4 years ago, # ^ |   +34 Oh, it seems it is my bug. Thanks. And I did it 12 years ago!The problem is from Saratov local contest of 2004.BTW, it is fixed. We will not rejudge contest solutions, but all other solutions have been rejudged.
 » 4 years ago, # |   +25 Regarding the language, I have one feedback comment for now.When I want a specific construct, I usually Google for it. For the things in the standard library (for example, set or regular expressions), the first link usually invites to read the official API Reference. Its pages list all methods, but I didn't find any single example each time I got there. And it is hard(er) to learn using a construct without an example readily available. So, I usually scrolled the Google results down to find the first link to StackOverflow, and it helped.The point is, for a new user, it would be nice if the examples came on the first link from a respective Google search. If that link is usually API Reference, it would be nice to have examples right in the API Reference.
 » 4 years ago, # |   0 Will there be an editorial?I really cant understand E,either my english is bad or this task is just a bit hard.
 » 4 years ago, # |   +13 Kotlin was indeed a fun language (no pun intended)
 » 4 years ago, # | ← Rev. 4 →   0 Thanks for this round, I had fun during the contest to discover a new language for me.