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

Автор wuhudsm, 10 месяцев назад, По-английски

A

code
solution

B

code
solution

C

code
solution

D

code
solution

E

The intended solution is $$$\Theta(n)$$$. However,if your implementation of $$$O(n\log n)$$$ solution is good, it is also possible to pass :)

There're several $$$O(n)$$$ solution.

solution1
code1
Solution2
code2

F

code
solution
Разбор задач TheForces Round #19 (Briefest-Forces)
  • Проголосовать: нравится
  • +43
  • Проголосовать: не нравится

»
10 месяцев назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

[Deleted]

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

    You can copy the code from the Editorial and submit it. After you get AC, you will be able to view the test data.

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

      can u explain how to get the d(n),w(n) for largenumbers(like 10^18) in efficient way ? sorry if i am pointless here.

    • »
      »
      »
      10 месяцев назад, # ^ |
      Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

      In this: You can copy the code from the Editorial and submit it. After you get AC, you will be able to view the test data.

      Then why I'm not able to view the test data of problems A, B? I got AC on both of them.

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

        Sry,it seems impossible to show test data in any gym contests

»
10 месяцев назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

what is w(n) and d(n) in editorial of C?

»
10 месяцев назад, # |
Rev. 3   Проголосовать: нравится +10 Проголосовать: не нравится
Am I wrong or solution for problem B is wrong on this case: N = 15, K = 4.

EDIT: fixed

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

    Answer is YES since 15 can be broken into 3, 3, 3, 6 with gcd = 3 > 1

    • »
      »
      »
      10 месяцев назад, # ^ |
      Rev. 4   Проголосовать: нравится +14 Проголосовать: не нравится

      I also said answer is YES but solution's(editorial's) answer is NO. Please read the comment carefully before replying it.

      EDIT: fixed

»
10 месяцев назад, # |
  Проголосовать: нравится +10 Проголосовать: не нравится

wasn't A supposed to be the easiest problem? the math was hard. couldn't solve it and get disapointed.

»
10 месяцев назад, # |
Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

Solution for B better than editorial.. It's sufficient to check the condtion for spf only And all test case can be answer in O(1) . Link for code: https://codeforces.com/gym/104455/submission/211966383

»
10 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

anyone explain D editorial is not clear

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

    You can refer to this code : https://codeforces.com/gym/104455/submission/211985521 First try to find the max possible ans.. which u can think like sum is fixed u have find max product ( which comes at middle) i.e. the max ans possible is ((n/2)*((n+1)/2)) and this will be possible when u will move (n-1)/2 steps downward (say node n1) and considering that node as ancestor connect all left node to its direct child.. And the min ans you can get here is when all node will be connected serial-wise or connected directly to node 1 which will be n-1.. So, if given x lie between min and max value means we can find a tree for x; To find a tree for a particular x we will find the difference between the max possible ans and the given x, then u will be known how much ans you have to decrease.. Accordingly we will connect those node to node 1 directly to reduce the max value. For further u can see the given code..

»
10 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

can some give example of A for clear understanding, how l1+r1>l2+r2 is answer??

»
10 месяцев назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Would you please investigate submission 212018133 (I submitted using one of my alts)?

It is copied directly from the editorial but also gets TLE on test6. It seems that we could only pass this problem using C++17, not even C++20, let along Python.

[user:wuhudsm][user:EndlessDreams]

»
10 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

For problem E:

It is also ok to directly swap $$$a$$$ and $$$b$$$ by symmetry, i.e., replace the line

for(int i=1,j=n;i<j;i++,j--) swap(a[i],a[j]),swap(b[i],b[j]);

with

for(int i = 1; i <= n; ++i) swap(a[i], b[i]);

But be careful, swap(a, b) would lead to TLE, because it will call

template< class T2, std::size_t N > void swap( T2 (&a)[N], T2 (&b)[N] ); (until C++11)

template< class T2, std::size_t N > void swap( T2 (&a)[N], T2 (&b)[N] ) noexcept; (Since C++11 Until C++20)

template< class T2, std::size_t N > constexpr void swap( T2 (&a)[N], T2 (&b)[N] ) noexcept (Since C++20)

See https://en.cppreference.com/w/cpp/algorithm/swap for detail. So swap(a, b) will run through the whole array and causes TLE.

Code:

Spoiler
»
10 месяцев назад, # |
Rev. 2   Проголосовать: нравится -11 Проголосовать: не нравится

My TLE (on test 6) solution during the competition (Using DDP+Segtree) is attached below. It might work if the time limit is looser:

Spoiler
»
10 месяцев назад, # |
Rev. 2   Проголосовать: нравится +20 Проголосовать: не нравится

Why are the problems deleted? I saw they'd faded away from submissions and also upon clicking on any problem via editorial, it says contest has not started yet.

»
10 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

why the contest is restarting?