Блог пользователя hitman623

Автор hitman623, 7 лет назад, По-английски

Hello Codeforces!

I would like to invite you to Manthan, Codefest'19, which will take place on Sunday, August 25, 2019 at 8:05 PM IST. This is a combined Div. 1 + Div. 2 round and is rated for participants from both divisions.

The Department of Computer Science and Engineering, IIT (BHU) is conducting Codefest from 23rd August — 25th August. Manthan, the algorithmic programming contest under the banner of Codefest, is being held as a special Codeforces round. The round follows regular Codeforces rules.

All problems in this round were created and prepared by drastogi21, _shanky, Enigma27, _hiccup, KAN and me (hitman623).

A lot of thanks to KAN, 300iq, vintage_Vlad_Makeev, _overrated_, Rox for the testing and valuable comments, and to MikeMirzayanov for the awesome Codeforces and Polygon platforms!

Prizes -

  • 1st place — INR 25,000

  • 2nd place — INR 18,000

  • 3rd place — INR 12,000

  • 1st place in India — INR 6,000

  • 1st place in IIT(BHU) — INR 3,000

  • 1st place among freshers (1st/2nd Year) of IIT(BHU) — INR 1,000

  • Codeforces T-shirts to the participants who will be the first to solve each problem.

Participants will be offered 8 problems and 2 hours to solve them. As usual, the scoring distribution will be announced later.

Hope you guys enjoy the contest! See you on the leaderboard!

UPD: The scoring is 500 — 1000 — 1500 — 2000 — 2250 — 2500 — 3000 — 3750

UPD: The contest has ended. Congratulations to the winners.

1. tourist

2. Um_nik

3. EvenImage

First place in India: cerberus97

Following are the participants who were the first to solve each problem and have won a Codeforces T-shirt. Congrats!

A. IgorI

B. Geothermal

C. icecuber

D. ILoLy

E. nocriz

F. GoGooLi

G. EvenImage

H. tourist

UPD: We decided to give the 8th T-shirt to IgorI for problem A. Congrats!

The editorial has been published.

Hope to see you next year!

  • Проголосовать: нравится
  • +661
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -56 Проголосовать: не нравится

Finally some Indian Contest ..waited for it ..hoping for great problems.. last one was great

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -131 Проголосовать: не нравится

Waited for the whole year! Hope the legacy of greatness continues!

»
7 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +6 Проголосовать: не нравится

Probably tourist will win the prize for 1st place ...

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

The Legends battle are coming

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -49 Проголосовать: не нравится

Hope that I'll become a candidate master after this round! Div.1 + Div.2 is a great chance to promote my rating and I only need +8 rating to become a candidate master :D. And also, good luck to everyone!

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +150 Проголосовать: не нравится

"Codeforces T-shirts to the participants who will be the first to solve each problem.", well, this gonna be interesting

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +45 Проголосовать: не нравится

    Yes,it will.And I think it doesn't matter if you do a great job or win a T-shirt or not,I think the
    feeling during the contest is the most exciting thing! And good luck to all of you!

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

Wow, an awesome contest ^_^

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится

1st place is constant for tomorrow's contest if he participates.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

8 problems, 4 for div 2, 4 for div 1 or another?

Sorry for my bad english

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -7 Проголосовать: не нравится

I'm disappointed they scraped my e-mail from my profile and decided to send me spam.

It is an old e-mail, meaning that they did it some time ago and not just now near this contest, and I've never registered in their site.

The closest I got was participating in Codefest '18, here in Codeforces, but at that time, I used a different e-mail (a third one).

PS.: And even if they did it at that time (they didn't), nowhere it says they would send e-mails to registered participants.

»
7 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +30 Проголосовать: не нравится

Manthan, Codefest 18 (rated, Div. 1 + Div. 2) The Previous Manthan codefest contest .

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

8 problems for 2 hours?? Isn't that too tight?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I hope that I will raise my rating to 1500-1600

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +17 Проголосовать: не нравится

Wow.... Such a big prize

$$$出题人家里有矿_{泉水}$$$

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Any update on scoring distribution?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I relize that lots of people use anime avatar like me ^______________^

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

None of the other severs (m1.codeforces.com), (m2.codeforces.com), (m3.codeforces.com) seem to have the contest added in there?!

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Have been participating regularly for the past 2 editions of this contest and had lots of fun.
Hope everyone has fun this time too :)

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

not able to register before 5 minutes of contest... why??

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

can someone submit? it keeps loading

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

It's legendary grandmaster battle. I can't wait to see that. All top 3 highest CF rating have already register, who will win???

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

R.I.P queue

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

VERY long queue

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What was the pattern for 1208C - Magic Grid?

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -36 Проголосовать: не нравится

B question was good. Took more than 1 and half hour to understand it what's it trying to say and implement it.

Thanks for this contest IIT BHU :) . Cheers!

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +23 Проголосовать: не нравится

How to solve C, it seems much harder than D and E

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

tourist achieved top 1 is really very normal =))

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve C?

I feel D was easier than C :(((

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Oh dear, I got bug at D.

    Dunno whether my C is correct. Btw I use the fact that I can construct a grid for numbers 0->15, then I could construct numbers for 16k->16k+15

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    U can find a pattern that if you break the given nxn matrix into 4x4 matrices with increasing values (For ex: 0 to 15, 16 to 31 etc) , you can make all the rows and columns have xor sum = 0.
    Find my submission here :)

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    This is my approach:

    Divide the whole matrix into 4 * 4 matrices. Then fill every matrix with slight modification of a valid answer for a 4 * 4 matrix. I used the result of test case 1 of the problem statement. Keep a variable that tells us the number of matrices that has been processed. Left shift counter variable by 4 and then perform bitwise OR operation with the corresponding number of the initial matrix while assigning.

    Will it be correct? Yes, because the XOR of each row and column of every 4 * 4 matrix will be the same. So, if you use test case 1, then the XOR of each row and column of the whole matrix will be 13 or 0.

    Will any number repeat? No, because we are using counter variable. Every number has 4 initial bits with 2 ^ 4 possible combinations. These are covered by the initial matrix. We just need to cover the extra bits. The counter gives us new combinations of the extra bits, starting from the lowest. By performing bitwise OR, we are reaching each bitwise combination. So, we will hit each number once.

    My submission can be found here.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

How to solve D ?

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +10 Проголосовать: не нравится

    I did it with a lazy segment tree, but there seems to be a way to do it with just a regular segtree/fenwick tree. In the sequence you get, the last 0 is always the 1 in the original. If you imagine that you remove the 1 you found and subtract 1 from every item after that you would get a similar sequence for 2..N. Then you find the last zero again, which now is the 2 and you subtract 2 from everything after etc. You use a lazy min segment tree to find the last zero (order by value and index) and to do the range subtractions.

  • »
    »
    7 лет назад, скрыть # ^ |
    ← Rev. 6  
    Проголосовать: нравится 0 Проголосовать: не нравится
    Spoiler
»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

most of the WA10 because of something like this :

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

What is test #5 of D?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

I was able to solve C but couldn't solve B. :( Was B more tough than it is supposed to be??

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +59 Проголосовать: не нравится

Thanks for the short statements

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -15 Проголосовать: не нравится

I must be crazy. I think the problem should be like ABEDCFGH...

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is there any way to solve D without converting it into a Segment tree RMQ problem? I saw the number of submissions and thought I probably need to think simpler.

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +12 Проголосовать: не нравится

When in the last 20 minutes of the contest you start doing problem D but in the last 9 seconds you submit it without any tests, because you just finished coding it, and you misstyped a -=, instead of typing +=. I've neve felt this bad before ;(

PS: Submission during the contest: https://codeforces.me/contest/1208/submission/59484539

Submission after the contest, after changing the signal: https://codeforces.me/contest/1208/submission/59486030

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

hard contest for me but I enjoy it very much. Thanks :)

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

How to solve E in time? I had a made a sparse table solution and then just iterated over all of the columns but I couldn't figure out the final optimization. At the end I tried to use a lazy seg tree to propogate the maximum over all columns where the the array can take all of it's values. Is this the right approach?

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -35 Проголосовать: не нравится

B and D are not good problems. C is nice

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +81 Проголосовать: не нравится

I love how tourist was able to get 500 on A (submision time 52s) :-)

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +72 Проголосовать: не нравится

The best utilization of last ( extra ) five minutes : tourist submitting H at 2:03

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится
»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Can someone give a quick editorial of B.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

Okay, why lot of system test fail on B?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +26 Проголосовать: не нравится

I solved C with something really easy: I print all even numbers first then I print what is left. For example for n=4 my output will be :

0 2 4 6 
8 10 12 14 
1 3 5 7 
9 11 13 15
»
7 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

so sad I thought C xor will be zero because it looked impossible to guess some number but didn't know how :'(

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +183 Проголосовать: не нравится

At least 3 persons on my friend list who got F accepted fail this test:

3
2 4 2

Please look into this.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

why codeforces don't compare codes like this 59482093 and this 59481769

tihs is not fare

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Can we solve B using Binary Search?

  • »
    »
    7 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +3 Проголосовать: не нравится

    Yes. I solved it using binary search. Code Search space is the answer range i.e. [0,n]. isValid function checks if it's possible to delete 'mid' number of values such that rest of them are distinct. I used map to store the values and their frequencies in the 'undeleted' array. If the size of map is n-mid for some undeleted part, it means that all the undeleted elements are distinct.

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I think you can.If deleting a large portion from a given position gives you a valid sequence then you can check for even smaller portion.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

What id test 54 for B ?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Guys, I've found a really nice solution for C.

The Ideea is this: Put even numbers in increasing order on odd rows and odd numbers on even rows.

Ex: n=4 0 2 4 6 1 3 5 7 8 10 12 14 9 11 13 15 This is 100% correct and much easyer to implement. :)

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

How to solve F?

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +11 Проголосовать: не нравится

    Could anyone explain why this solution 59478005 for F works?

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +29 Проголосовать: не нравится

    My solution: We want to be able to fix a_i and compute the best (a_j&a_k) for that a_i quickly. To do so, we iterate through i from large to small, and maintain an array cnt[bit] which stores the number of elements among $$$a_{i+1}, a_{i+2}, ..., a_{n}$$$ that have bit as a submask. How to we update cnt? Note that we only need to know if cnt is >= 2 or not. Now, when we have a new element $$$x$$$ to be added, we do something like a dfs, starting by adding 1 to $$$cnt[x]$$$, and then recursing on all submasks of $$$x$$$ that are one bit away from $$$x$$$. If at any point of time we visited the same number or cnt[x]>=2, we can terminate because we know all submasks must also have cnt>=2. Thus, the complexity of updating cnt is amortized $$$O(n\log a_i)$$$. Finally, with the values of cnt you can also find the best answer for a fixed $$$i$$$ in $$$O(\log a_i)$$$ time.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

can you tell, where my code for B fails?

My Solution

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Why does solution for B in $$$n^2 \log^n$$$ give TLE? I used both binary search and sets (I know it's not the most efficient), and couldn't get it accepted. TLE on test 18. Can anyone help?

$$$n^2\log^2n$$$ is roughly 43587196 ops at n=2000 which should work in under 2secs imo.

Submission

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +4 Проголосовать: не нравится

Can someone please point out the logic flaw in my solution for problem B?
PS: Found my mistake. Thanks everyone.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

Можно ли как-то полностью посмотреть 85 тест в задаче B, так как на нем программа выдает неверный ответ?

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I didn't leak code to anyone but I receive system's message :'(. May be this is an accident

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My Solution for B, fails on test 54 but I don't know why? Someone please help! LinkL: https://codeforces.me/contest/1208/submission/59459333

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +59 Проголосовать: не нравится

So tourist doesn't get two T-shirts? :sad:

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -128 Проголосовать: не нравится

It is totally unfair to me . I have solved the second problem completely with required time complexity even than your website is showing TLE . Why? Do something otherwise it is totally waste of time for me to participate in challenges on your website

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +51 Проголосовать: не нравится

I was able to pass pretests with my too complicated solution for G, but I got TLE on one of the pretests during system testing. Moreover, after the contest I submitted the same code 10 times, 9 of those 10 attempts got AC. Maybe solutions should not be rerun on pretests during final testing, to prevent such disappointing situations in the future xD

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +59 Проголосовать: не нравится

1179 contestants solved segment tree problem. It seems like CF is "growing up" or I am "growing down".

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +27 Проголосовать: не нравится

tourist returned to 3700+ in 31 months.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone tell why my code 59471606 of B problem gave wrong answer on pretest 9? It gives same output as jury's output when I run it in my system.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve D,I don't understand the editorial ?

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    If the input is valid, as the problem statements says, there is always an answer and it will be unique.

    Let's build from the last element in the array to the first one. Also create a data structure that can query the sum of all values in range[0, r] and update a point in log.

    Whenever you try to put some number into the answer, it will have sum of all the other unused numbers, because they will be somewhere before it in the answer. Initially, all numbers are available. So you can do N updates like: update(i, +i).

    As you know the sum of all numbers before it in the array, just binary search what element have exactly the same sum as the input, then remove it from the answer like: update(i, -i).

    Suppose that you initially have 1, 2, 3, 4, 5. So, your data structure will be: 1, 3, 6, 10, 15.

    If you want to put an element with sum 6, you should put element 4 as the last one, then your data structure will look like this: 1, 3, 6, 6, 11.

    Keep doing this and you will end up with the answer.

    • »
      »
      »
      7 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +6 Проголосовать: не нравится

      It seems a same approach with mine (and different with the editorial).

      However, I don't know how to deal with such condition:

      n=5, the sequence is 0 4 0 1 1

      0 1 3 6 10

      (the last one is 2)

      0 1 1 4 8

      (the last one is 3)

      0 1 1 1 5

      Now, there are three 1 can be chosen (in fact, the third 1 is correct), and how can my program deal with such condition in appropriate complexity.

      • »
        »
        »
        »
        7 лет назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        You should always try to find the last one element that have the same sum. If the data structure is like ... 0 1 1 1 1 2 ... And you are searching for 1, just get the last 1.

        If you put another value except from the last, you can't build the answer.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +54 Проголосовать: не нравится

How is it possible to solve A in 52 secs if statement loads for half a minute xD?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Tourist is such a monster!

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think we should swap problem C and problem D.....

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I tried to solve the second question using binary search on the length of segment to be removed. The pretests passed but I got TLE in the final testing.

http://codeforces.me/contest/1208/submission/59462841

Can someone tell me what went wrong ?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -6 Проголосовать: не нравится

why I dont see the prize for first solve of problem H in the list above while there is someone has solved this in the contest, can anyone explain this for me?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve G? It seems like a math problem about divisors, and the AC code looks very simple. However, I did not understand the behind logic yet. Anyone can help?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone help me with the code for B problem? Here is my code:

#include <bits/stdc++.h>
#define ll long long int

ll n,m;
ll a[4004];
// set<int>s;
map<int,int>mp;
int last[4004];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[n+i] = a[i];
    }
    for(int i=1;i<=2*n;i++)
    {
        last[i] = mp[a[i]];
        mp[a[i]] = i;
        // cout<<last[i]<<" ";
    }
    // cout<<endl;
    int ans = 0;
    for(int i=1;i<=n;i++)
    {
        int cnt = 0;
        for(int j=0;j<n;j++)
        {
             if(last[i+j]<i)
             {
                cnt++;
                ans = max(ans,cnt);
             }       
             else{
                break;
             }
        }
    }
    cout<<n-ans<<endl;
    return 0;   

} 
»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can Any one explain Problem D ??

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

Request for future contests :: Please make large inputs downloadable

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

If you've solved problem D. And want to solve another interesting problem like this. Try Lightoj — Lining Up Students In Lightoj one need a account in case of view a problem. In case you don't have an account there you can read the problem here

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -34 Проголосовать: не нравится

asd

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -35 Проголосовать: не нравится

hello my fan

»
7 лет назад, скрыть # |
 
Проголосовать: нравится -44 Проголосовать: не нравится

Codeforces is too easy to me

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Can I get some help to solve B...This was my code https://codeforces.me/contest/1208/submission/59474361 ...Why am I getting TLE...As much as I can see, the solution will execute 6.4*10^7 instructions at max

  • »
    »
    7 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +4 Проголосовать: не нравится

    Operations on unordered_map are often more than 1 instruction, and the $$$O(n^{2}logn * map)$$$ will probably have a bad constant and run for longer than expected.

    Some improvements:

    The actual elements in the array don't matter, only that they're unique. Therefore, you can compress coordinates and use a boolean array (or bitset, if you really want) instead of a map. This alone should get you under TL.

    The binary search doesn't actually help you. Since the check function is $$$O(n)$$$ anyway, you may as well get rid of the $$$logn$$$ factor by just finding the first location, iterating from the right to r, that creates a duplicate (of course, include the elements to the left of l first and account for duplicates there)

    And because three is a good number, even though this isn't necessary, your loop in check skips over a lot of elements. Each continue can cost you, and it will be better to split check into two loops.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Was anyone able to get AC with binary search on B ? If yes can you share your solution ?

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +14 Проголосовать: не нравится

The problems are good.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hmmm. Is the difficulty point of H right???