kostka's blog

By kostka, 10 years ago, In English

Still in buoyant humour after Good Bye 2014? While waiting for the editorial, maybe you would like to know why there were so many hacks in the last round of this year?

As always, please share you thoughts, ideas or maybe hacks :)

Previous posts can be found here.

Stats

Problem Successful hacks Unsuccessful hacks Other* Sum Solutions which can be hacked Accepted solutions All solutions on final tests Hackers efficiency**
500A - New Year Transportation 199 (40.61%) 124 (25.31%) 167 (34.08%) 490 375 (9.32%) 3650 (90.68%) 4025 34.67%
500B - New Year Permutation 738 (67.40%) 214 (19.54%) 143 (13.06%) 1095 573 (24.89%) 1729 (75.11%) 2302 56.29%
500C - New Year Book Reading 0 (0.00%) 9 (75.00%) 3 (25.00%) 12 23 (1.08%) 2114 (98.92%) 2137 0.00%
500D - New Year Santa Network 4 (26.67%) 3 (20.00%) 8 (53.33%) 15 150 (16.82%) 742 (83.18%) 892 2.60%
500E - New Year Domino 0 0 0 0 8 (3.77%) 204 (96.23%) 212 0.00%
500F - New Year Shopping 0 0 0 0 1 (3.03%) 32 (96.97%) 33 0.00%
500G - New Year Running 0 0 0 0 0 0 0

*one of the: INVALID_INPUT, GENERATOR_INCOMPILABLE, GENERATOR_CRASHED, IGNORED, OTHER.

**suggested by marat.snowbear and Yura_Sultonov — hacked solutions / (hacked solutions + solutions which failed on final tests).

Here should be graph.
Here should be graph.

Hacks and possible hacks description

500A - New Year Transportation

Test #13 is pretty worth seeing:

4 4
2 2 1

Also, many hacks was something like:

n n
1 1 1 1 1

Many people forgot about last cell (the n-th one), maybe because of input.

Here should be graph.

500B - New Year Permutation

Because there are no editorial yet, I have to say something about one solution which passed all pretests and was hacked many times.

It was just greedy swapping positions if it was possible, like this:

while(swapped)
{
   swapped = False
   for i=1,2,...,n
     for j=i+1,i+2,...,n
        if M[i][j] and p[i] > p[j]
           swap(p[i],p[j])
           swapped = True
}

You may see that for such test:

3
2 1 3
001
001
110

the output for this algorithm would be 2 3 1, when you can simply make 1 2 3 (2 1 3 -> 2 3 1 -> 1 3 2 -> 1 2 3).

Probably, it was also included in test #15.

Thanks to tbm, Aeon and minty99 for finding mistakes.

Here should be graph.

500C - New Year Book Reading

Here should be graph.

500D - New Year Santa Network

With this problem, you may noticed that it could be problem with big values. Really big values... Let's think about simple tree: a lane (with edges 1—2, 2—3, 3—4, ..., n - 1n). Let's say that every edge cost d and we suppose that we choose vertex with number one as one of the Santas' warehouse. We can notice that the approximation of the summarized cost for all networks with 1 is already pretty big:

With n ≤ 105 and d ≤ 103 can be little too big even for 64-bit numbers (the sum above was only with one fixed points).

Thankfully, we just needed to count expected cost, so with some division we can do it with long longs — you just have to be careful with calculations.

It was checked by test #22.

Here should be graph.

500E - New Year Domino

Here should be graph.

500F - New Year Shopping

Here should be graph.

500G - New Year Running

Here should be graph.

Fastest hackers

Problem Time Hacker Defender Hack
500A - New Year Transportation 0:08:44 ondrah AboveWood 130441
500B - New Year Permutation 0:43:02 yuusti rui-de 130478
500D - New Year Santa Network 1:34:07 TMandzu JATC 130897

Best hackers

Hacker Stats Successful hacks Unsuccessful hacks
liympanda +12-1 (1150) A: 131631 131687 131942 132007
B: 131199 131236 131268 131284 131304 131315 131341 131506

B: 131415
maximumSHOT +12-2 (1100) A: 130682 130712 130725
B: 131391 131460 131514 131767 131801 131839 131864 131894 132002
A: 130654
B: 131683
Misha100896 +13-6 (1000) A: 130451 131330
B: 130993 130998 131011 131024 131028 131038 131042 131050 131086 131176 131632
A: 130459 131276
B: 131057 131074 131109 131131
kzyKT +10-0 (1000) B: 130576 130592 130661 130685 130711 130752 130825 131031 131528 131895

ddt +11-2 (1000) A: 130543 131420
B: 131088 131139 131167 131188 131218 131230 131242 131693 131860

B: 131195 131277
albertg +11-3 (950)
B: 130489 130492 130502 130510 130516 130526 130669 130693 130907 131500 131550
A: 130787 130812
B: 130498
Antoniuk +10-1 (950) B: 131178 131206 131224 131244 131267 131282 131335 131351 131400 131435
B: 131255
sparik +9-0 (900) B: 130578 130709 130729 130739 130746 130753 130760 130820 131294

kozinov +9-1 (850) B: 131614 131662 131694 131716 131738 131775 131805 131891 132027
B: 131831
akashdeep +10-3 (850) B: 130584 130924 130956 130971 130985 131006 131021 131047 131058 131087
B: 130520 130690 130741
shilov +8-0 (800) B: 130811 130829 130840 130873 130913 130981 131098 131689

Ra16bit +8-0 (800) A: 131099 131115 131190 131211
B: 130821 130854 130868 130941


InheritG +8-0 (800) B: 131451 131472 131512 131562 131602 131758 131783 131956

Artem_kh +8-0 (800) A: 131094 131210
B: 130799 130814 130871 130940 131137 131162


SirShokoladina +8-0 (800) B: 131647 131707 131761 131782 131816 131897 131953 131975

Programist +9-2 (800) B: 130708 130754 130774 130807 130815 130836 130844 130898 131213
B: 130560 130763
I_love_Tanya_Romanova +8-0 (800) B: 130499 130501 130503 130505 130514 131091 131297 131841

chaotic_iak +8-0 (800) A: 131132
B: 131427 131478 131526 131568 131597 131606 131625


niyaznigmatul +8-0 (800) A: 132013
B: 131014 131025 131032 131046 131055 131063 131650


aliasadiiii +8-1 (750) B: 131609 131665 131676 131697 131803 131848 131885 131915
B: 131984
tuna_salad +8-1 (750) A: 131875 131890 132032
B: 131273 131298 131316 131338 131508

B: 131257
SAKT +8-1 (750) B: 130893 131001 131065 131072 131089 131126 131152 131228
B: 130961
Honour_00 +8-1 (750) B: 131452 131636 131659 131669 131677 131688 131750 131777
B: 131914
rituranjna +8-1 (750) B: 130536 130555 130570 130586 130635 131120 131172 131554
B: 130566
yuusti +7-0 (700) B: 130478 130481 130488 130491 130602 130611 130615

tourist +7-0 (700) B: 130646 130653 130662 130672 130675 130692 131358

dreamoon_love_AA +7-0 (700) B: 130603 130607 130617 130622 130630 130637 130640

Tviskaron +8-2 (700) B: 131507 131548 131579 131607 131621 131635 131655 131674
B: 131639 131696
Isfandiyor +7-0 (700) A: 130482 130496 130504 130508 130535 130638 130819

VeniVidiVici +7-0 (700) B: 130486 130494 130495 130766 130776 130960 131291

deleteeeeeeeeed +9-5 (650) B: 131366 131373 131380 131390 131398 131413 131421 131448 131454
B: 131434 131466 131475 131518 131541
xxTastyHypeBeast666xx +7-1 (650) B: 131422 131666 131695 131718 131763 131772 132016
B: 131501
Foy1998 +7-1 (650) B: 131532 131675 131715 131766 131788 131853 131908
B: 131752
aandrukhovich +7-1 (650) B: 131353 131485 131583 131617 131653 131935 131985
B: 131774

Best rooms

Room #hacks Hackers
21 14 Misha100896 [13], smv98 [1]
30 14 maximumSHOT [12], osank [2]
3 13 kozinov [9], KonanMentor [4]
51 13 ddt [11], kefaa [2]
141 13 Artem_kh [8], Damon [4], Reyna [1]
12 12 Programist [9], VietaFan [1], Zhandos [1], 31201153 [1]
20 12 kzyKT [10], sivukhin [2]
27 12 SirShokoladina [8], mohamednabil00000 [2], AGrigorii [1], m.h [1]
69 12 liympanda [12]
92 12 Isfandiyor [7], domen111 [5]
9 11 Marcin_smu [6], Milanin [5]
39 11 ilyakor [6], HYPERHYPERHYPERCUBELOVER [3], dwoolley3 [2]
40 11 svanidz1 [6], ASverdlov [4], Shapo [1]
82 11 redoak [6], rasinhas [4], zhabo [1]
87 11 albertg [11]
134 11 shilov [8], TONYTRAN [2], Mohammad_Yasser [1]
10 10 aandrukhovich [7], Kareem [2], SamanSami [1]
50 10 tourist [7], Lee_vincent [2], DimaPhil [1]
78 10 Horea [6], JoeyWheeler [2], MrSunday [2]
83 10 sparik [9], nguyenchicuong [1]
89 10 Antoniuk [10]
95 10 akashdeep [10]
143 10 Honour_00 [8], ngochai94 [2]

Best countries

Country #hacks Hackers
Russia 182 Misha100896 [13], SirShokoladina [8], Tviskaron [8], niyaznigmatul [8], shilov [8], Artem_kh [8], Vaness [7], Nikitosh [6], VArtem [6], redoak [6], Petruchcho [6], Lelby [6], Romchela [6], Petr [6], qwerty787788 [5], gepard211 [5], Um_nik [5], Milanin [5], alberist [5], ASverdlov [4], Sert [4], el_sanchez [4], KBOPYM [3], al13n [3], Babanin_Ivan [3], Schullz [3], knst [3], SlavaSSU [3], Merkurev [3], sivukhin [2], GlebsHP [2], AGrigorii [1], Igorjan94 [1], pvs [1], Malinovsky239 [1], HolkinPV [1], ultizet [1], Belonogov [1], AndreySiunov [1], arturom [1], Shapo [1], Sinner [1], Slamur [1], GoDDoS [1], shevk [1], enot110 [1], DimaPhil [1], nic11 [1], DmitriyH [1]
Iran 65 aliasadiiii [8], SAKT [8], poopi [6], somag [5], mosiomohsen [5], spOoky [5], hsnprsd [4], Damon [4], oofldw289 [3], ashkan_d13 [3], No0oB [3], M.Mahdi [2], Kianoosh [2], Haghani [1], JeBeK [1], taki [1], Reyna [1], NikaraBika [1], MHR [1], m.h [1]
India 59 ddt [11], akashdeep [10], rituranjna [8], logic_max [6], girish347 [4], swap [3], rivudas [3], osank [2], anudeep2011 [2], abhay26 [2], grayhathacker [2], PraveenDhinwa [1], ShekharNain [1], utsav_deep [1], SameerGulati [1], ashu1461 [1], anuraganand [1]
Belarus 58 Ra16bit [8], aandrukhovich [7], tourist [7], sas4eka [6], subscriber [5], KonanMentor [4], omse1998 [3], Rostislav_the_great [3], AlvinMax [3], greencis [3], Yury_Bandarchuk [2], kefaa [2], taxicoo [1], vitux [1], sdryapko [1], wilcot [1], vilcheuski [1]
China 55 liympanda [12], InheritG [8], zerotrac [5], SanSiroWaltz [4], hzt1 [2], MrSunday [2], last_one [2], tianchouczl [2], Lee_vincent [2], chuizi [2], Skyshirk [2], LGWLGWLGW [2], mathlover [1], C_SUNSHINE [1], BrightestSirius [1], Dwayne [1], JCsoulsky [1], JayYe [1], only_998 [1], v-guihom [1], 31201153 [1], wangchaohui [1]
Japan 54 kzyKT [10], yuusti [7], rng_58 [6], kmjp [6], ChronoireSchwarzVI [5], atetubou [4], zeosutt [3], kakira [3], iga-c [3], dai1741 [3], evima [1], wrong [1], DEGwer [1], UminchuR [1]
Ukraine 45 Antoniuk [10], Programist [9], I_love_Tanya_Romanova [8], sdya [6], MrDindows [5], KADR [5], DJiGIT [1], ibra [1]
Brazil 32 tiagob.reis [7], Juniorandrade [7], ffao [6], fulvioabrahao [4], rasinhas [4], thiagocarvp [3], marcoskwkm [1]
Egypt 31 Killever [5], Noureldin [4], Walid_Amin [3], MahmoudAGawad [3], zetamoo [3], TahaMahmoud [3], Kareem [2], mohamednabil00000 [2], hamedArafa [2], BitHashTech [1], Mohammad_Yasser [1], AhmedAtef07 [1], ahmad_mamdouh [1]
Vietnam 28 Foy1998 [7], phankhai [5], ngfam_kongu [4], dnk [3], sillyboy [2], TONYTRAN [2], ngochai94 [2], vodanhna [1], nguyenchicuong [1], duyduc [1]
Armenia 22 albertg [11], sparik [9], armand [2]
Poland 22 Marcin_smu [6], kostka [5], Errichto [5], dj3500 [3], liadoon [2], akrasuski1 [1]
Kazakhstan 21 Aeon [6], a_kabdygali [5], SmallBoy [3], ADJA [2], mexmans [2], Na2a [1], Zhandos [1], zhabo [1]
Taiwan 18 dreamoon_love_AA [7], paulwang [6], domen111 [5]
Indonesia 14 chaotic_iak [8], PieceOfCode [6]
Bangladesh 12 Honour_00 [8], the_redback [2], ashiquzzaman33 [1], imtzhsn [1]
Switzerland 12 W4yneb0t [6], ilyakor [6]

Thanks for reading and happy New Year!

  • Vote: I like it
  • +116
  • Vote: I do not like it

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

In problem B, you have written, (swapping first 3 with 1 and then 1 with 2) if initially the array is 2 1 3 then swapping 3 with 1 will give 2 3 1 then swapping 1 with 2 will give 1 3 2. How I can simply make 1 2 3 ?

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

    2 1 3 -> 2 3 1 (swap(2nd, 3rd)) -> 1 3 2 (swap(1st, 3rd)) -> 1 2 3 (swap(2nd, 3rd))

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Sorry for mistake, I tried to swap the output instead of input :)

»
10 years ago, # |
Rev. 2   Vote: I like it +10 Vote: I do not like it

In the wrong code example of problem B:

if M[i][j] and p[i] < p[j]

I think it should be "if M[i][j] and p[i] > p[j]" (Because we should make the small numbers to the front of permutation)

Thanks for your great post!

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah, thanks for pointing it out. :)