By JetBrains, 5 weeks ago, In English,

Hello, Codeforces!

First and foremost, we would like to say a massive thank you to everyone who entered and submitted their answers to the first and second Kotlin Heroes competitions which was held previously. Congratulations to the top 3 winners:

Episode 1

  1. Petr
  2. ecnerwala
  3. eatmore

Episode 2

  1. tourist
  2. eatmore
  3. Benq

Ready to challenge yourself to do better? The third "Kotlin Heroes" competition will be hosted on the Codeforces platform on 27.02.2020 16:35 (Московское время). 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 will again be held in accordance with a set of 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). If two participants solved the same number of problems and scored the same penalty, then those of them who had previously made the last successful submission will be given an advantage in the distribution of prizes and gifts.

Registration is already open and available via the link. It will be available until the end of the round.

REGISTER →

If you are still new to 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 the solutions are open, which means that you can look at the solution even if you haven't solved the problem yet. The practice round is available by the link.

We wish you luck and hope you enjoy Kotlin.

Announcement of Kotlin Heroes: Episode 3
 
 
 
 
  • Vote: I like it
  • +181
  • Vote: I do not like it

»
5 weeks ago, # |
  Vote: I like it +12 Vote: I do not like it

So cool

»
5 weeks ago, # |
  Vote: I like it +12 Vote: I do not like it

good luck!

»
5 weeks ago, # |
  Vote: I like it +32 Vote: I do not like it

I've written a blog with some notes about using Kotlin in competitive programming.

Note that Kotlin Heroes rounds tend to be more generous than usual rounds on the time limits.

Good luck to everyone!

»
5 weeks ago, # |
  Vote: I like it +13 Vote: I do not like it

Can previous winners get prizes one more time?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Yes, the winners will receive their prizes regardless of their participation in the previous rounds.

    • »
      »
      »
      5 weeks ago, # ^ |
      Rev. 2   Vote: I like it -22 Vote: I do not like it

      yes, that's great :). I don't need money, I need the only Tshirt :)

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

The link for the practice round is wrong. It references Kotlin Heroes Practice 2. There is a Kotlin Heroes Practice 3 here

»
5 weeks ago, # |
  Vote: I like it -7 Vote: I do not like it

Going to take t-shirt

»
5 weeks ago, # |
Rev. 4   Vote: I like it -8 Vote: I do not like it

map < int, int > mp;
mp[10] = 2;
mp[10]--;
if(mp[10] > 0) cout << "yes";
else cout << "no";
Can anyone convert this c++ code into kotlin?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    yes

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Here you go:

    val mp = mutableMapOf<Int, Int>()
    mp[10] = 2
    mp[10] = mp.getOrDefault(10, 0) - 1
    print(when {
        mp.getOrDefault(10, 0) > 0 -> "yes"
        else -> "no"
    })
    
    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +9 Vote: I do not like it

      In C++ mp[10] would create a missing key with a default value, so the true Kotlin equivalent to mp[10] in C++ is mp.getOrPut(10) { 0 }. However, this code assumes that we definitely have the element in the map, so it would be truer to its spirit to write mp[10] = mp[10]!! - 1 or mp[10] = mp.getValue(10) - 1.

      The other is that there's really no reason to replace if with when. In Kotlin if works just as well as in C++.

      P.S. There are no C++-style maps that would create missing elements in Kotlin out-of-the box, but you can easily write one yourself and then write your code just as you did in C++, e.g. you would be able to write mp[10]-- just as you did in C++. See the example here: https://pl.kotl.in/v8JTqsAe_

      • »
        »
        »
        »
        5 weeks ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        (Oh my God! Roman Elizarov wrote a response to me!)

        Of course you're right, I guess I made a too high-level translation, trying to also convey my own perception of Kotlin's functional/call-by-reference/null-safe spirit.

        I like how in Kotlin, like in C++, you can go as high or low-level as you need, and mix and match such code as it is convenient.

        P.S. Didn't know that mp[10]-- was possible in Kotlin.

»
5 weeks ago, # |
  Vote: I like it +47 Vote: I do not like it

Guys, I wanna ask shouldn't the random prizes be only for non-new IDs to prevent people from making fakes just for this contest(to increase chances in random). PS: Was motivated to write this after seeing unusually high number of black IDs on the leaderboard

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it +9 Vote: I do not like it

    +1 Would be nice to block those fake IDs

  • »
    »
    5 weeks ago, # ^ |
    Rev. 4   Vote: I like it 0 Vote: I do not like it

    Such things should be clarified before the contest. Elsewhere, it will not be fair to the participants which decided to register here just to take part in this particular contest.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      Yeah bro, I totally respect the people who made an ID just for this maybe, but I just was talking about some people including multiple fake IDs to win.

      And I totally get it that rules should be pre-declared, all I'm saying is there should be some counter-measures to stop this immoral and unethical practice!

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it +2 Vote: I do not like it

        Yeah, I fully agree that such behavior is against the spirit of competition because it gives some users more chances to get prize and I agree that we need to do something with that. The question is how we can prohibit that? Proposed way to exclude new users from the raffle is not appropriate because of:

        1. As I stated above: "it will not be fair to the participants which decided to register here just to take part in this particular contest".
        2. Some fake accounts are not created recently. Moreover, they could took part in few rated rounds, so it will be quite hard to determine that they are fakes.
»
5 weeks ago, # |
  Vote: I like it +25 Vote: I do not like it

When can I submit >:(

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone run the program about random winners please?
https://codeforces.com/blog/entry/69419?#comment-541391
first — 451, second — 650.

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it +6 Vote: I do not like it

    62 64 65 74 76 82 103 115 122 129 147 149 167 191 201 207 223 224 244 264 281 285 306 308 318 320 330 332 343 345 356 363 396 422 423 439 440 452 476 483 486 488 514 538 550 594 601 605 633 640

»
5 weeks ago, # |
  Vote: I like it +10 Vote: I do not like it

The hardest thing is to make a valid comparator fo TreeSet in "F".

Can anybody give me expl of such comparator for TreeSet for Pair<Int, Int>(comp must work as usual sort)?

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    I've found such thing:

    var opened = TreeSet<Pair<Int, Int>>(compareBy({it.first}, {it.second}))

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    (The type of the TreeSet is inferred by the type of the comparator)

    val pq = PriorityQueue(compareBy(Pair<Int, Int>::first))
    

    (the type of the PriorityQueue is inferred from the type of the comparator)

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Is it possible to submit now out of contest? OK, apparently NOW :D

»
5 weeks ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Thank you for the contest. It was my first one. How can I get a T-Shirt? Upd. It seems I haven't won any. There are several people on #122 (

»
5 weeks ago, # |
  Vote: I like it +22 Vote: I do not like it

When will the cheaters be dropped from the standings and most importantly, when will the winners be announced?

»
5 weeks ago, # |
  Vote: I like it +34 Vote: I do not like it
»
5 weeks ago, # |
  Vote: I like it +142 Vote: I do not like it

Our congratulations to the t-shirt winners (top 50 + random 50)!

List place Contest Rank Name
1 1297 1 Egor
2 1297 2 tourist
3 1297 3 Benq
4 1297 4 darnley
5 1297 5 eatmore
6 1297 6 Deemo
7 1297 7 Heltion
8 1297 8 uwi
9 1297 9 Nebuchadnezzar
10 1297 10 Golovanov399
11 1297 11 pitfall
12 1297 12 pr3pony
13 1297 13 natsugiri
14 1297 14 knightL
15 1297 15 gwq2017
16 1297 16 mraron
17 1297 17 xiaowuc1
18 1297 18 Fortin
19 1297 19 BohdanPastuschak
20 1297 20 Aleks5d
21 1297 21 nuip
22 1297 22 ToMmyDong
23 1297 23 Spheniscine
24 1297 24 Quang
25 1297 25 nmakeenkov
26 1297 26 nantf
27 1297 26 dalt
28 1297 28 Jeffrey
29 1297 29 Taran_1407
30 1297 30 DarkKeks
31 1297 31 SYury
32 1297 32 eulerscheZahl
33 1297 33 wleung_bvg
34 1297 33 U.M.R
35 1297 35 IgorSmirnov
36 1297 36 microtony
37 1297 36 WiwiHo
38 1297 38 armoking
39 1297 39 vadimmm
40 1297 40 Flyce
41 1297 41 Baliuk
42 1297 42 artsin666
43 1297 43 nhho
44 1297 44 Alexandr_TS
45 1297 45 DishonoredRighteous
46 1297 46 tatyam
47 1297 47 camypaper
48 1297 48 ulna
49 1297 49 lucifer1004
50 1297 50 codelegend
62 1297 62 alan8585
64 1297 64 user202729_
65 1297 65 gleb.astashkin
74 1297 74 jtnydv25
76 1297 76 jonas.havelka.42
82 1297 82 Jason5Lee
103 1297 103 HanaYukii
115 1297 115 hrynb
122 1297 122 srikkanthr
129 1297 129 mainstring
147 1297 147 CrazyPants
149 1297 149 DemoVersion
167 1297 167 gultai4ukr
191 1297 190 __mdsinalpha__
201 1297 201 kazuki08
207 1297 207 chrome
223 1297 223 maxwill
224 1297 223 Tigmah
244 1297 244 balint4229
264 1297 263 Dibro
281 1297 281 _Binary_Search_
285 1297 285 TripleFrequency
306 1297 305 RTX2080
308 1297 308 all_too_well
318 1297 318 killua1zoldyck
320 1297 318 devcrocod
330 1297 330 _.mohito._
332 1297 331 forgotter
343 1297 343 tiemonl1
345 1297 343 T3sserac7
356 1297 355 sasfmlzr
363 1297 363 NewUser0
396 1297 393 cerber_urs
422 1297 422 bouxroix
423 1297 422 IloveRachelEternally
439 1297 436 chakwok
440 1297 436 TToPoCeHoK
452 1297 451 slivets.aleksay
476 1297 475 Mehulagrawal
483 1297 483 OnceUponTheTime
486 1297 483 upsolving
488 1297 488 Dungeon..Master
514 1297 510 Atticus
538 1297 537 XinLoiNguoi
550 1297 550 imunique.zj
594 1297 592 sorcerer_98
601 1297 599 A_Fan_of_the_AK_King--lk
605 1297 605 Suifeng0214
633 1297 633 Misha_Help
640 1297 640 D_J_Z
  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it -39 Vote: I do not like it

    Why new fake accounts get prize?

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it -32 Vote: I do not like it

      16 Black IDs out of random 50 T_T

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it -31 Vote: I do not like it

        16 This is too much, If they are removed, we will have another chance.

      • »
        »
        »
        »
        5 weeks ago, # ^ |
        Rev. 2   Vote: I like it +98 Vote: I do not like it

        I'm NOT a fake account. I'm new to codeforces but I have been using Kotlin for my personal development for a while. Please don't judge an account by its color.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it -19 Vote: I do not like it

          Sorry bro, didn't really intended to offend anyone, already said that I respect everyone who gave it fairly, just still don't u see an unusual number of new IDs?

          • »
            »
            »
            »
            »
            »
            5 weeks ago, # ^ |
              Vote: I like it +84 Vote: I do not like it

            The unusual number of new IDs for Kotlin Heroes contest was to be expected. This contest was specifically designed to attract developers who never had prior competitive programming experience before and was marketed by JetBrains throughout a very large Kotin developer community.

            • »
              »
              »
              »
              »
              »
              »
              5 weeks ago, # ^ |
                Vote: I like it -28 Vote: I do not like it

              Oh very well, hopefully there will be much more new registrations in Kotlin Heroes episode 4.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +13 Vote: I do not like it

    when we will get our t shirts?? Is there any procedure to complete for getting t shirts??

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +13 Vote: I do not like it

      I can't give you details for this contest, but from my experience with other contests: you will get contacted, either per eMail or private message. Depending on the organizer this may take 2-3 days or even more than a month in some cases, 9 months till it finally arrived :(. I'm not saying that it will take that long (I really don't know in this case), just don't get nervous when you have to wait a bit.

      Then you have to provide your address and tshirt size (replying to the message directly or filling a web form).

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Based on the previous two experiences, in about two months System will remind you via Talks to check and be sure that your profile contains complete and actual information about t-shirt size and shipping address. About another month after that the T-shirt will be sent from Russia and System will give you the tracking code.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It would really help if the organizers could give out online certificates, in pdf format, for the participants with their respective ranks.

  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Is there any chance of getting a T-shirt for those having a Tie? @Suifeng0214 and me have the same rank but unluckily i am not selected.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think, that need more t-shirts

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    :v

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I share rank 363 with NewUser0. Will I get t-shirt?

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

good luck everyone!

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Hello :) Thank you for a cool contest. Will there be an editorial, please?

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

eluded this time as well. Cant believe that i could not be in the 12:1 as well.

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

any reliable sources for learning kotlin? please help.