By awoo, history, 7 years ago, translation, In English

Hello Codeforces!

On February 16, 18:05 MSK Educational Codeforces Round 38 will start.

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

This round will be rated for Div. 2. It will be held on extented ACM ICPC rules. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 7 problems and 2 hours to solve them.

The problems were prepared by Ivan BledDest Androsov, Sahand Xahandd Alitanloo and me.

Thanks Mike MikeMirzayanov Mirzayanov for great system Polygon!

Good luck to all participants!

UPD: Since there will be another Div. 2 contest soon, the hacking phase will be shorter (only 12 hours). Before CF Round 464 we will actualize the registrations in such a way that Div. 2 will be officially registered, and Div. 1 participants — unofficially.

UPD2: We also have a message from our partners Harbour.Space:

We are excited to announce that some of the world’s strongest teams will come to our Hello India x Russia Programming Bootcamp: MIPT and all top India’s Universities that qualified to the World Finals!

As always, the boot camp isn’t only about the training — we’re in the process of getting renowned keynote speakers from all over the globe to come and speak about life and all the opportunities at your fingertips after ACM-ICPC.

We look forward to seeing you all there this spring! For those of you who haven't registered, there's still time.

Register here

If you have any questions we can help you with, please connect with us:

Phone number: +34 674 291 422 Email Address: [email protected]

UPD3: Editorial is published

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

| Write comment?
»
7 years ago, # |
  Vote: I like it +34 Vote: I do not like it

sooo fast people, wait we're still in a contest

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

lol

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

Imagine if we have rated contest every day! That actually happened for three days. Actually four(Saturday contest)

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Score distribution?

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

Hat-trick of Rated Contests! :O

»
7 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Wow! Rated educational rounds are really great initiative for div2 contestants. Just ❤️ it!

»
7 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Will educational rounds normally have 7 problem from now on?

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

A back to back series of contests continues.......

»
7 years ago, # |
  Vote: I like it +30 Vote: I do not like it

Wow, four rated contests in four days. Keep it going Codeforces! :)

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

just like if we are in the heaven , Contests everywhere :D

»
7 years ago, # |
  Vote: I like it +14 Vote: I do not like it

Maybe educational rounds should be rated for div 3 :) just like atcoder abc contests.

»
7 years ago, # |
  Vote: I like it +12 Vote: I do not like it

many contests! it's a chance for me to rescue my rating.

»
7 years ago, # |
  Vote: I like it +31 Vote: I do not like it

Let's see how many hacks halyavin takes in this round! XD

»
7 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Codeforces seems to be quite excited. 4 rated contests continuously. Wow !

»
7 years ago, # |
  Vote: I like it +2 Vote: I do not like it

It's a week of "Love to Contests" !

»
7 years ago, # |
  Vote: I like it +20 Vote: I do not like it

My life these days,

Eat — sleep — codeforces contest

REPEAT

»
7 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Our recursive routine these days : contest->upsolve->contest->upsolve->contest..........

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Is hacking solution outside the room allowed during the contest time ?

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

    Are there rooms in this contest?

»
7 years ago, # |
  Vote: I like it +36 Vote: I do not like it

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Help: what is the difference between an educational contest and an ordinary contest?

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

    ER features trivial/classic problems, don't be surprised if you have seen some of them before

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +4 Vote: I do not like it

    Ordinary contest:

    • Different points on different problems

    • Hacks in-contest (you can't hack after round)

    Educational contest:

    • Problems have the same points (like ACM — ICPC rules)

    • Hacking phase opened after round. Usually it's 24 hours (but it's 12 this time).

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

    Ordinary contest: Computer is used to test solutions.

    Educational contest: a human named halyavin is used to test the solutions.

»
7 years ago, # |
  Vote: I like it +9 Vote: I do not like it

halyavin is waiting for this contest.

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

»
7 years ago, # |
  Vote: I like it +18 Vote: I do not like it

I'm getting codeforces crashes in the last 3 contests I've been participating, I cannot submit solutions...I'm getting: Ooops! Something has broken down in Codeforces. Do not panic, you can try to reload the page or return Home. Anyway we will carefully read megabytes of logs, analyze stacktraces and fix the problem.

etc... and pictures of bug "ALL YOUR BUG ARE BELONG TO ME" — "I'd rather feel they're mine"...

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

    This has also been happening to me sometimes in contests

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

    clear your caches and cookies, maybe your csrf token is not refreshing

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

      My friends lokpati and bitcyber face similar issue in almost all contests. Whenever they click submit button , it doesn't proceed to 'status' page. Also they do not get any error message like mihelifi . MikeMirzayanov can you look into the issue?

      P.S: They have pretty fast Internet connections.

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

        look for errors in console, also see post request in network tab, what do you see when you submit?

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

          IMG_20180217_020414254_BURST000_COVER_TOP See the little spinning icon on the right side of submit button(which usually appears for a moment after you click submit) .In their case, it keeps spinning and this page does not proceed to 'status' page.Same happens even if they submit code via CF editor. I hope I've made the point clear.

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

            It happens to me when i go back and forth after putting a hack testcase for someone.

            To fix that, i copy url, close the tab. reopen in tab and paste url.

            on the surface it seems once a pub sub connection is opened in a tab, it doesn't allow new connections unless old one is closed. I havent investigated much though.

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

              Will tell them to use this trick. Thanks

      • »
        »
        »
        »
        7 years ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        I faced a similar problem, here is a verified solution:

        It happens when you write like this:

        some code{

        }

        instead write this way -

        some code

        {

        }

        It may appear silly, but it works, see it for yourself.

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

          What???!!! :D Ok, we'll change the coding style too, if that's the issue. :D Thanks for your valuable suggestion.

»
7 years ago, # |
  Vote: I like it +11 Vote: I do not like it

How to solve C?

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

    First, note that we are essentially just solving .

    So iterate over n, check if n2 - X is a square, and check whether m exists that satisfies the condition. The appropriate bounds for n are easy to find. Each TC will run in .

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

      do we need to start the iteration from 10**9 ? Seems pretty large but maybe the loop doesnt run full?

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

        I used the bound mentioned below by barkingdog, so I iterated n from 1 to about . (Of course, after handling edge cases)

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

          why do you need isqr method? doesn't casting double to ll just remove fractional part?

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

            To be absolutely sure, i think. Another example, when string has not more than 1e6 chars, many create char[100005];

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

              Do you mean char[1'000'005]? That's why I just use std::string.

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

      if we factorize the left side we can iterate over divisors of X

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      Can you explain the equation: n^2 - (floor(n/m))^2 = X? Why and how you derived it? rkm0959

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

    Given x, first You have to find n, k such that n^2-k^2 = x, and second check and find whether n/m = k is possible.

    Since n^2 <= 4/3*x, the range of n is not that big, and you can easily match k for all n which satisfies x <= n^2 <= 4/3*x by check whether n^2-x is square. Then by calculate candidate of m = n/k, you can know whether n/m = k is possible

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

      I want to ask u 1 thing that how do u have come to the conclusion that n^2<=4/3*x ?

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

        maximum number of zeros you can have is when m = 2, and it will be n^2/4.

        and x = ones ..so minimum value of x = n^2 — (n^2/4) (when m = 2) ; so x = 3/4 *(n^2) at least.

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

          minimum value of x or maximum value of x?

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

            minimum value, x will be at least that much, in other cases when m = 3,etc. x will be even more

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

How did you do D?

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

    Using Greedy & Priority queue, expand the routes by increasing order of cost of arriving concert.

    Since number of road is also small, you don't have to care about multiple visit.

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

      Essentially Dijkstra's algorithm starting with all vertices in the priority queue.

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

        Doesn't that take too long? It's NlogM * all vertices.

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

          You don't run Djikstra's on every vertex, you run it once but starting with every vertex in the priority queue. Initially every vertex is pushed with a weight equal to a[i], and then Djikstra's is the same from then on.

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

          You may create one "new" vertex and conect it with all other vertices puting the walue of the road equal to a[i]. Then run Dijkstra algo from it. And it will work N*logM.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

https://pastebin.com/7f6WPztq

Can anyone tell me why my code wouldn't work for D? It kept on failing on test case 3. :(

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +8 Vote: I do not like it

    You can take a path through multiple cities that might be cheaper.

    Say the concert costs are 100 100 1 And the edges are 1 2 1 2 3 1

    Then it's cheaper to take both edges from city 1 to city 3. Your code only considers taking 1 edge.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Any idea of hacking yet ?

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

is G using idea similar to solving dynamic connectivity offline.But now maintaining basis of cycles possible in that component also and maintaining components as dsu with weights on edges for maintaining xor distances.
Or any other easy solution???

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

    You may maintain the base of cycles by Gaussian elimination. Since the size of each base is not larger than 30, and each edge adds at most one number to the base, we can easily rollback the base in dynamic connectivity.

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

      How to solve F??

      • »
        »
        »
        »
        7 years ago, # ^ |
        Rev. 4   Vote: I like it +8 Vote: I do not like it

        There is a simple solution: dp[m][mask] — best answer if we considered first m characters of the string and a mask of erased substrings.

        Let's try to speed it up. If there are two states dp[m1][mask1] and dp[m2][mask2] such that the lengths of strings in these states are equal, but dp[m1][mask1] < dp[m2][mask2], then we are not interested in state dp[m2][mask2] at all. So let's change our dynamic programming to dp2[m][mask] = 1 if we can reach this state with optimal answer (and otherwise it's 0).

        To calculate it, you have to iterate on the ''layers'' of states (here by layer I call a set of states with equal length of resulting strings) and find the minimum character that allows to go to the next layer from the current one.

        Its complexity is , but in fact it's pretty fast since most states are unreachable.

        Code: https://pastebin.com/K5cHmbgs

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

      Isn't it ?

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

        If we consider xor to have complexity O(1), then it's since checking if a number belongs to the base can be done in time .

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

          Probably I need to wait for editorial. I don't understand how you are doing dynamic connectivity offline with gauss. For me it seems that when you merge two components you will need to do gauss in for numbers.

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

            We don't have to store a separate base for each component. Since the graph always stays connected, we may instead store a base of all cycles in the graph (even if some of them are disconnected now, they will become connected later).

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

              That makes sense. Thanks.

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

              But if the graph is not connected. then we cannot do better than O(logC*logC) for merging two guass right??
              Also in this question except to eliminate the logC in complexity,is there any other need of connected graph??

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

        My (really ugly) code of that complexity passed in under 700ms. http://codeforces.me/contest/938/submission/35374477. It'd be fun if someone hacked it :D

»
7 years ago, # |
  Vote: I like it -16 Vote: I do not like it

I have been trying 1 hour with this solution. Can someone plz tell me what is wrong with this solution https://ide.geeksforgeeks.org/s3ldY59oii

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

    I didn't completely go over your code yet, but using int for x seems a bit dangerous.

    You are calculating x * x sometimes, where x may run up to 105. Yet you used int for x...

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

      I defined int as long and long. And i also checked for random 100 cases > 1e8. No time limet exceeded. I also compared 10 to 500 but no errors. But i cant find what is wrong. Ill again go to specialist. For the past few contests my rating are going down. But as i solve problems more and more my ratings are going down. Few contests back for some contests, i solved D, E etc but recdently im completely fucked up.

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

        Excuse me but where did you define int as long long? I only saw you define ll as long long. Would you please point it out? Thx a lot.

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

        Few contests back for some contests, i solved D, E etc but recdently im completely fucked up

        its good to be frustrated. use that energy next time.

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it
        #define f(i, x, y) for(int i = x; i < y; i++)
        #define all(X) X.begin(), X.end()
        

        why aren't you using templates, this can lead to bugs which will waste time at the least.

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

          How it can be replaced by templates? 1) something like

          f(0, 100, [](int i){
              //...
          })
          

          imho isn't simpler than just for() 2) I have no ideas how to make same with templates

          (I don't use such macros, I don't think they give speedup)

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

            I was wrong. I think they are fine. Just need few more brackets to be sure.

            Personally i think it might give speed up to people who make typo when trying to type faster (like me). Those typos sometimes irritates and takes brain bandwidth.

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

              template 2 isn't fine:


              vector<vector<T>> table; auto it = table.begin() + i; sort(all(*(it++))); //expected sort(table[i+1].begin(), table[i+1].end()) //after macro substitution sort((*it++).begin(), (*it++).end()); //which means sort(table[i+1].begin(), table[i+2].end()) //->ERROR
»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

could someone help me with problem B my code

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

    Try 2 600000 800000

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

    Here's my code: https://pastebin.com/attptiBj

    Basically, the key thing for B is to

    1. Make sure that if you are moving simultaneously
    2. In order to make sure you don't over or undercount intervals, try each interval.

    Find the minimum distance from current start to the next interval greater, and current end to the previous interval smaller, then shift whatever is closer.

    This prevents you from moving a large interval and missing certain intervals.

    So for start = 1, end = 10^6. If the intervals are 1, 500000, 600000, you don't want to be double counting 400000+500000, because if you moved 400000 on both sides, then you only have to move an additional 100000 from start to get to 500000.

    Constantly update start and end with the new closest intervals to count correctly.

    You also want to break out of the program and return when start and end intersect, which signals that you have seen all the intervals so you should exit.

»
7 years ago, # |
  Vote: I like it +9 Vote: I do not like it

In problem C,I wonder we can hack only with testcases equal to one, but how about those coder whose solution may got time limit exceed due to more testcases?

»
7 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Problem C: I'm really confused by the case2,can anybody express it?thanks so much

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

What is the difference between these two solutions ?

WA

AC

How priority queue works in both the cases?

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What's "Unexpected verdict" when I try to hack others?

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

del

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Idea for E?

I find some equation but it is O(N^2)...

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

    For E. First by sorting, compress the array as (number, occurrences).

    Now, we will calculate how much time each number will by added in our summation.

    Let's look at this number x — say there are u occurrences of x, and there are v numbers that are larger than x. Then, x appears in our summation if and only if the v numbers that are larger than x appear AFTER at least one x appears. The "probability" for this is , so the number of permutations that add x to our summation is . Now it's just some partial sums, easy calculation. Time Complexity just for sorting.

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

      Ohhh.. I see... Thanks!

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

      But is there another way of calculating the number of ways for all v's to be after x? I don't know how probabilities work in this kind of cases so another solution would be clearer. This code seems very nice but i can't understand the part with binom(n,c) .

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

        That's because the numbers which are larger than x should appear after at least one x,but the numbers which are smaller than x could appear anywhere.So you have to location the smaller numbers,which're (c is the size of smaller numbers),and c! for every permutation,then the larger numbers(or equal numbers) should fill the last positions,which is (n - c - 1)!,and the position for x is settled.

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

          Ohhh, ok, thank you very much!!! Now i got it.

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

        can u tell me what inv[] and ifac[] mean ?

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

          inv[i] is the modular inverse of number i and ifac[i] is the modular inverse of i! (i factorial). You can learn about it on the internet. It is the way of calculating combinations for large numbers.

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

      why the "probability" for this is u/(u+v)? isnt it u!*v!/((u+v)!)?

      • »
        »
        »
        »
        7 years ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        Since there are u+v numbers which are not small then x, x appears if and only if the first of the u+v numbers is equal to x. There are u numbers same as x, the probability is u/(u+v)

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

can i hack soultions if i haven't submitted any solution? Does it count for any rating changes?

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

Yazdanra is a genius cheat! lol!! he submitted multiple solutions for the same question from another account Double-D (owned by him) in which a specific case will fail and then he hacked all of them from his real account!!! ![ ]() isn't that totally unfair!

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

    Yeah, that's definitely bannable.

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

    Hacking doesn't benefit the hacker in educational rounds, apart from getting a green plus next to your name in the standings.

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

      Is the prelim standing final for div2 rating changes? P.S. : I haven't participated in the contest.

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

        No. Ratings will be updated after the 12 hours when after the actual system tests finish.

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

    Poor fella doesn't know hacking will not affect his rating.

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

    That is just stupid. One has no profit of hacking himself in this round.

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

    So in a way he hacked the hacking system ...lol

»
7 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Why does the meaning of the term "submatrix" in task C differ from conventional one? "A submatrix of a matrix is obtained by deleting any collection of rows and/or columns." https://en.wikipedia.org/wiki/Matrix_(mathematics)#Submatrix

Here "submatrix" means some square area of adjacent elements. That's misleading!

»
7 years ago, # |
  Vote: I like it +22 Vote: I do not like it

There is no need for System test, we already have one halyavin :D

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone tell me what's wrong with my approach for D. link

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

anyone can tell me the difference between GNU C++ 11 & GNU C++ 14?

this one is my submission during the contest, which got tle on testcase 37.

35369457 (C++ 11)

and this one is my submission right after the contest, which is exactly same code with above, and got ac.

35370185 (C++ 14)

only difference between two submissions is the language i choose...

got confused

»
7 years ago, # |
  Vote: I like it +20 Vote: I do not like it

Lel, in my language vowels are considered to be 'a', 'e', 'i', 'o', 'u', and I didn't read that there was 'y' as well xD

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What's with the time and memory limits in codeforces rounds? I find them way too harsh. Today I got TLE on F with an O(n2) solution (if we take that operations with integers take O(1) time), and memory limit exceeded on D using Dijkstra's algorithm.

Of course, there may be something wrong with my code (Problem D, Problem F), but I don't see it. Do you? >:)

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

    Maybe it won't help you, but try to add

    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    to your D submission. My solution is using Dijkstra to, and it passed tests and is not hacked yet. Also, recently I have TL due to missing io boost

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

      That sped it up quite a bit, but it didn't reduce the memory consumption. :/

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

      If I use "ios_base::sync_with_stdio(false); cin.tie(nullptr); " what is the benifit of this ???

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

        By default, you can mix c++-style io (cin cout) with c-style(scanf printf) without any problems (it should work as expected), but results in performance. ios_base::sync_with_stdio(false) — disable this sync-tion. cin.tie(nullptr) disable sync-tion of cin and cout.

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

    Not sure, but in F it seems (for * (for auto) * (for .. state.second) might be n3.

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

    use normal array for dist[] and link list for edges instead of vector?

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

    It took me a while but I found the mistake. In the edge loop inside the while you put the weight into a variable that is declared as int, that makes it overflow and possibly means an negative loop so it makes sense that it is MLE. http://codeforces.me/contest/938/submission/35380385

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

In problem C,can anybody explain why the answer is 999954147 when n=36514,m=2? thanks so much

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

    you need to write one zero in four squares.

    i mean, you can write zero in (x, y) if x and y are both even, otherwise write one

    then you can write 36514*36514*0.75=999954147 one(s).

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

    I think it should be 36514*36514-[36514/3]*[36514*3]

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

      why?

      i think you mean you will put only one zero(0) in 3*3 square,

      but you can find 2*2 square which doesn't contain any zero(0)s.

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

how to hack person ?

»
7 years ago, # |
  Vote: I like it +6 Vote: I do not like it

In C answer for 48 is 8 2 for many people but for 8 2 maximum possible ones are 55. Can someone tell where I am wrong. Thanks in advance.

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

    i think so,8*8-3*3,why is this wrong?

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

    maximum possible 1's = n*n-(n/m)*(n/m)

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

      yeah you are right,i was stupid

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

      What is the max possible value of n and m

      In question it is given 1e9 but can it ever reach 1e9?

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

        max possible N will be sqrt((4*x)/3)

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

          Thank you. Could you please tell how to find the maximum value. I was thinking something like this n*n*(1 — 1/(m*m)) = x so n*n = x if I assume 1/(m*m) to be small enough so n = sqrt(x).

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

            n will be maximum when m=2 hence n*n-(n/2)*(n/2)=x therefore (3*n*n)/4=x hence n=sqrt((4*x)/3);

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

      ok got it

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone tell me if my approach for D is correct? The contest ended before I got to finish it..

For each component of the graph, I will construct it's MST, because no answer for any node will contain an edge not present in the MST(needs proof).

Then, I choose a root for each tree and start traversing from root to leaves(dfs2), and for each node I will update it's answer as following: ans[current]=min(ans[current],ans[child]+2*edge(current,child))

The initial answer for every node is it's concert price.

Then I will do another dfs(dfs3), this time; I will update the answer of the child with the answer of it's parent(going up).

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

    It needs: https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm And using MST doesn't help, because you need to use the sum of the weights, not the max.

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

      MST for MinimumST. I still don't see where it doesnt work.

      Anyway, can you elaborate more? How do I apply Dijkstra on the graph?

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

        cmon, i know you can do it by yourself, don't spam :) It is a simple algorithm, easier than Kruskal's or Prim :)

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

          No no I know the algorithm very well, I also thought about using it in the contest, but I have no idea HOW to do it for every node

          I'll find out..

          Thanks a lot, you've been very helpful :D

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

            Let's say a concert is a vertex. Create the graph that the problem gives to you but with weights doubled. Also, create edges from the concert to vertex i with weight a[i]. The distance between the concert and vertex i is exactly what you want so just start from the concert.

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

I have been trying 1 hour with this solution. Can someone plz tell me what is wrong with this solution https://ide.geeksforgeeks.org/s3ldY59oii. No TLE . I also compared 10 to 500 but no errors. But i cant find what is wrong. Ill again go to specialist/pupil. For the past few contests my rating are going down. But as i solve problems more and more my ratings are going down. Few contests back for some contests, i solved D, E etc but recdently im completely fucked up.

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

    Your output for 3 is -1, but correct output should be 2 2.
    Don't be upset if u can't solve much problems. You do your best, and try to upsolve them after contest. Rating really doesn't matter, whether you are pupil or expert. (Sorry for bad english)

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

      Yes, Rating doesnt matter, but i cant find the simple error and i make many silly mistakes and if a new problem comes, only if i ve already seen it previously, i can solve it, else i cant. I dont know how many problems i need to see. I ve already seen more than 1500 to 2000 problems, and still not a CM or even expert, as i ll go down now.

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

        more problems you solve, more you will able to find the logic behind a problem. Again don't think that you are not CM or expert.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Do successful hacking attempts provide the challenger with extra points in educational rounds? I was lucky enough to make my first successful hack in an educational round, and wanted to learn about this since the scoreboard does not show any points, or changes in my standing. (i.e. rank)

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

    No, hacking in educational rounds doesn't increase nor decrease your points.

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

Can someone hack my solution for D?

I sort edges, then I look at every edge and try to improve answer for every verticle:

If I have an edge from a to b which costs d, and ans[a] > ans[b], I make ans[a] = min(ans[a], ans[b] + 2 * d); ans[b] = min(ans[b], ans[a] + 2 * d) otherwise.

I do this stuff 50 times, then output the ans array.

Sorry for my english btw.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

who can explain dotorya's C? link

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

    We should find such n and m, that
    It means , or t1 * t2 = X in his notation.
    It means that and and .
    Then check if condition holds and print n and m

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

When we'll be able to see tests on which solution was hacked?

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

    Tests are visible after the end of hacking phase.

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

      Thanks :)

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

      hi, could you explain your solution for C? i see many solutions that use % 2 but can't understand their logic

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

        I need to solve x = u^2 — v^2 = (u — v) * (u + v). So I factor x into 2 factors. But not all factors produce integer u and v. I can restore integer u and v from factors f1 = u — v and f2 = u + v if and only if f1 equals f2 modulo 2. Since the answer of the problem equals n^2 — [n / m]^2, I have n = u and can restore m from v.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

The last was a bit difficult

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

    Well I don't think so. It's super easy, especially compared with round #462...

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

In problem D, why my solution that uses SPFA got TLE in the last test(test17), is it a requisite to use dijkstra to calculate the minimum route in this problem?

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

http://codeforces.me/contest/938/submission/35361791

Can i know why i got hacked in TLE (prob.D) ? with dijkstra?

PS. What a newbie's mistake !! everybody thank you !!

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

    You can check the single vertex up to n times. If this vertex has degree n, you have O(n2) operations.

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

    Your solution does't work with two components. Try this test

    4 2
    1 2 1
    3 4 1
    1 10 1 10

    Answer must be 1 3 1 3

    P.S. Sorry,false alarm. Didn't read code correctly.

  • »
    »
    7 years ago, # ^ |
    Rev. 4   Vote: I like it +3 Vote: I do not like it

    NoTalentBug you make unnecessary vertex run(n^2), look my solve

    Example:

    1. was g[k].cost = 9,

    2. you updated it g[k].cost = 8,

    3. but you RUN EDGES CYCLE for old value and new

    (Sorry for bad english)

    void Solve()
    {
    	while (!pq.empty())
    	{
    		auto top = pq.top(); pq.pop();
    		int64 v = top.second;
    		int64 cost = top.first;
    		if (g[v].cost != cost) continue; // it important !!!!!!! 
    		for (const auto& it : g[v].e)
    		{
    			int64 to = it.to;
    			int64 costEdge = it.cost;
    			int64 newCost = costEdge + cost;
    			if (g[to].cost > newCost)
    			{
    				g[to].cost = newCost;
    				pq.push({ newCost,to });
    			}
    		}
    	}
    }
    
    
»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Waiting for rating?? SubSpring

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

Where is the system testing?

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it -20 Vote: I do not like it

    There is no system testing. These are the final results. Now we are just waiting for the rating.

    (THE ABOVE INFO IS WRONG !!!)

    Sorry for that!

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

      There will be system testing brother. All the hack cases will be added and the solutions will be rejudged.

»
7 years ago, # |
  Vote: I like it +31 Vote: I do not like it

Will the system testing and rating update happen before the next contest starts?

»
7 years ago, # |
  Vote: I like it +37 Vote: I do not like it

Where is the system test?
Where is the tutorial?

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

    You can usually expect tutorial no later than 24 hours after the end of the contest (coding phase in this case).

»
7 years ago, # |
  Vote: I like it +29 Vote: I do not like it

emmm..when will the rating change? Next contest will come.

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it +18 Vote: I do not like it

    But the bad news is that the system test hasn't begun yet... There are still only two test cases for problem C. According to the rules, all the hacks will be added into test data and rejudge. I'm wondering why it's called final standings instead of current ones...

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

      AFAIK In every educational rounds after Hacking phase it says
      Final standings, open hacking phase finished
      But after that System test starts.

»
7 years ago, # |
  Vote: I like it +46 Vote: I do not like it

Here comes "Codeforces Round #464 (Div. 2)" and the ratings haven't been updated yet. So what will happen if some 1800-rating person who should gain +200 rating in the last round takes part in the #464?

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

    If the ratings aren't updated before the contest, one possible solution is to evaluate the ratings of Education CF Round and then make it unrated for the people who became Div 1 in that round.

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

      that's a solution, but that would consume people's time and then after that make it unrated. Like I wouldn't want to participate if it's unrated for me, but it's hard for me to decide now, since I don't know whether it would be rated.

»
7 years ago, # |
  Vote: I like it +35 Vote: I do not like it

So when will the rating change?The next contest is coming soon.And the editorial hasn't been published either.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can u write the tutorial for this Ed.Round please

I don't understand in which moment I should stop search the answer and write "-1" (938C - Constructing Tests). Could somebody help me with it?

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

what about the rating for div2?

»
7 years ago, # |
  Vote: I like it +6 Vote: I do not like it

When will the system test begin?

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Holly Dijkstra, nobody hacked my D! For one second I did dijkstras from the cheapest cities, and in the other second I did iterations of bellman ford.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

is it rated??

»
7 years ago, # |
  Vote: I like it +4 Vote: I do not like it

If you try to use a case in which t=100 and all x=1000000000 in CUSTOM INVOCATION, then you will find an amount of solutions in problem C will get time limit at the last of sorted by Execution Time

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

    The system test is really weak and we are forbided to hack with t over 1.I think that shall be a point for hacking

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

      Why are those solutions slow, are they doing more than sqrt(10**9) operations?

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

      If we can hack with t over 1,we have to wait much more time for the system test.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

In Question C, for input = 21, why isnt "5 4" a valid solution?

Suppose we have a 5X5 square with all 1s except on the 4 corners where we have 0s, then if I have to select a 4X4 squares, there are 4 squares of 4X4 I can choose and each of them would contain a 0.

Please correct me if I'm wrong, help is appreciated.

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

    then if I have to select a 4X4 squares

    not "a" but all such 4X4 squares should be with atleast 1 zero

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

    Because we need to maximise the number of 1s.

    Therefore, the input 5 4 will likely generate a matrix like this

    1 1 1 1 1
    1 1 1 1 1
    1 1 1 1 1
    1 1 1 0 1
    1 1 1 1 1
    

    which have 24 1s.

    Indeed, if the problem asks for 24 instead, then 5 4 will be a correct solution.

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).