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

Автор Livace, 8 лет назад, перевод, По-русски

Привет, Codeforces!

Codeforces Round #483 пройдёт во 15.05.2018 17:45 (Московское время). Раунд будет рейтинговым для обоих дивизионов.

Задачи подготовили FalseMirror, KAN и я.

Большое спасибо тестерам qoo2p5, manoprenko, AlexFetisov, winger, cyand1317 и ashmelev.

Отдельная благорность MikeMirzayanov за Codeforces и Polygon и ifsmirnov за jngen.

И несколько слов от MikeMirzayanov:

Спасибо фонду Botan Investments и лично Виктору Шабурову за поддержку и поздравления c 8-летием! Горжусь нашим знакомством и возможностью помочь фонду запускать интересные программы! Напомню, что Botan Investments ведет регулярную работу по поддержку спортивного программирования в РФ: грантовая программа для преподавателей и 50000 рублей гроссмейстерам из регионов РФ работают уже несколько лет. Здесь вы можете ознакомиться с отчётами фонда и найти ссылки на интересные посты droptable (и в ВК-группе https://vk.com/botaninvestments).

Upd. Разбалловка 500-1000-1500-2000-2500 для div2 и 500-1000-1500- 2250 -2500 для div1

Поздравляем победителей!

div1:

  1. fateice
  2. skuecrk
  3. Egor
  4. dotorya
  5. LHiC

div2:

  1. wevetriedly
  2. mraron
  3. dummyies
  4. fengsuiyan
  5. K.F.Cat

Разбор

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

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

how many problems ?

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

Judging from the name, it seems like a round in honor of people who donated some satisfying amount. Why are such special rounds not held on weekends so that as many people as possible could participate? Also maybe include some more information about the sponsors in the announcements.

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

My rating is waving on the border of specialist and pupil these days.

And bless everybody and me to get more rating in this contest.

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

It is raining contests...!!!

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

Don't worry that your division can change after ratings update after Codeforces Round 482 (Div. 2). I'll fix all the registrations to match your actual division.

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

Both divisions ? Now we have three in Codeforces ! Thanks Codeforces

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

I believe if it is a thanks round, then the blog post should include some information and thanking for the supporters in this round. Otherwise it'll be no different from a normal round.

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

Accidentally downvoted :(

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

Contests everyday, thank you

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

what does jngen mean???

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

Contest of Div1 and ((div2 — div3) union div3) ) :P

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

These guys will beat tourist :

  1. gautam1212
  2. __B
  3. sarthak0797
»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hopefully, (Div. 2) Problems will be interesting like today's one.

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

Wow, there are real jngen users :) I haven't promoted it for several months, so I'm very happy to see that sort of self-promotion exists.

I would be glad if you could share the problems with me after the round. If I see how the community uses the library I can maybe improve the docs, give you some advice or see new development directions. My polygon login is the same as here.

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

Wow, nice short description. Hope the description of the problems will be as short as the blog. :)

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

My semester final exam start from today and I am waiting for Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!] :).

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

My rating is below 2100 but I cannot register at the home page.

Please fix the bug. MikeMirzayanov

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

Hopefully.

Candidate master still participate in div 1 round.

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

She: "What would you do alone at home?"

Mobile chimes, " Codeforces Div ..."

He: "I am not alone, anymore."

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

"Гожусь нашим знакомством", "лично Виктор Шабурову"

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

you said the round rated for both divisions

is it rated for div3?

or div3 is n't a division

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

is it rated for DIV-3?

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

Q. Why did Scarlet witch fell in love with Vision?

A. He was Red. :P

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

Заиграет ли velheor в Na'Vi?

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

10 min delay. why?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -49 Проголосовать: не нравится
Комментарий удален по причине нарушения правил Codeforces
»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -9 Проголосовать: не нравится

Problems difficulty is Unbalanced at all A and B**** are extremely easy compared to C and D

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

No Hacks !!

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

I solved problem C without the condition of 4 guys in the elevator, and was thinking why I had got WA 4 during all contest.

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

What's the point in making such a tough TL in div1A? Nice problems btw.

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

Is Div1 E just finding greedily till lca from both nodes and summing it??

Also is Div1 B using SOS dp or something easy??

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

    I did simple interval dp with precalculating function on all intervals.

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

    Easy.
    dp[l][r] = max(dp[l][r-1], dp1[l, r]) where
    dp1[l][r] = max(dp1[l+1][r], dp2[l, r]) where
    dp2[l, r] = (dp2[l][r-1] ^ dp2[l+1][r])
    calc dp2 for all [l, r], then dp1, then dp.

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

    Is Div1 E just finding greedily till lca from both nodes and summing it??

    Almost. The way I see it, you should go greedily (precomputing jumps by 2^k buses up) and stop before reaching lca, then check if the two vertices you stopped at can be connected by 1 bus. That check seems harder to me, I solved it using offline+sweepline+segtree in or , but I'm sure there's a simpler solution.

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

      That check is equal to query "Is there any number from interval [tinx, toutx] in the subtree of vertex y?" so it can be done with simple merging of sets.

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

        Ah, you mean numbering buses by one end vertex (with subtrees=intervals) and looking for them in subtrees by the other end vertex?

        My solution represents each "do we need 1 bus?" query by a rectangle formed by the intervals corresponding to the subtrees of its end vertices and each bus by a 2d point formed by the coordinates of its end vertices (both sorted to avoid casework). I avoid using a 2d interval tree by sorting and sweeplining by one coordinate, using an interval tree with operations "add/remove labeled interval" and "check off all intervals containing some point". In the end, I made it have amortised complexity per query, it's just more work and a clever structure.

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

    I think you need to know whether you can "save one bus" because the stops from both subtrees are connected by the same bus.

    Since I'm not too sure how to phrase that properly, maybe I'll just highlight the problem by asking a simpler problem: Given 2 nodes, how do you know if they are connected by a bus (i.e. answer = 1 for that query)?

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

How to solve C?

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

Hack-Free contest !

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

I realized that the TITLE of the Problem Div2D,Div1B was such a huge hint, but it was too late. no time to debug.

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

Problem Div.2 C

What is the answer for :

1 1000000000000000000 999999999999999999 10

the calculator shows : 1000000000000000000/999999999999999999 = 1.000000000000000001 which is finite

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

Thanks Botan Investments for my decreased rating...

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

For div2d, I thought of some kinda O(N^N) preprocessing but I had no clue how to calculate f() efficiently.. What is the idea behind this problem ?

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

Может быть, авторы перестанут ставить ограничение по времени 1 секунду в задачах, где много ввода????

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

how can we solve problem D , i know we need to find max xor pair in given range , but how to optimise it from o(n^2) ?

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

To be honest, I must appreciate how setters choose cases for pretests in this one — really careful and cover nearly everything one can slip into. Cheers. ;)

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

too tight time limit on Div.2 C....

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

Anybody else wants to complain against time limit of div1 A?

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

    me, i even made a comment in russian

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

    It depends on what is an intended complexity. Firstly I did something like log times gcd per testcase (which is O(log^2)) and it turned out to exceed TL. Then I did some optimization which looks silly, but I think it may actually improve complexity and passed in TL/3. However this task is actually doable in O(log(log(b + q)) per testcase, because it suffices to check if q|b64 which can be done with 6 multiplications if we have big integers or __int128_t that Codeforces doesn't have (taking mod q after each step of course).

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

      I tried bigint solution with python, and got TLE..

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

      I have log times gcd and it got AC. On the other hand, the numbers I'm computing gcd from decrease very quickly — it's "while Q > 1 compute gcd(B, Q), divide Q by it as many times as possible".

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

        That's what I did in the end as well. I mean you and I both finally have "while Q > 1 compute gcd(B, Q), divide Q by it as many times as possible", but in the beginning I had "while Q > 1 compute gcd(B, Q), divide Q by it" without "as many times as possible". I am not sure what is the worst case complexity of this solution, but after some thought I got an impression it is really useful and it is not as silly as it looks.

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

          For having "while Q > 1 compute gcd(B, Q), divide Q by it as many times as possible", it may takes even longer time in worst case. An example is q = 260, b = 231 then gcd(q, b) = 231 but we can divide it only once. However to check whether dividing it one more time is possible, we have to compute a division to check its remainder. (That cause extra time)

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

            Yes, in some cases it may be worse but thats not a worst case. In your example in next iteration we will have gcd=2^29 and divide everything, so there is only 2 computations of gcd(which also has divisions btw). If you divide by gcd once you have up to 60 iterations of gcd (which gives per test comlexity. If you divide while you can, it's no more then sqrt(60) iterations of gcd, which gives you (and comment shows that complexity may be shown to be

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

        I'm pretty sure this is asymptotically faster. It's no more that O(sqrt(log()) iterations of gcd because you divide by numbers with different number of primes each time

        (and may be it's even faster)

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

        If you do that + making B = gcd(B, Q) after not being able to divide makes the complexity O(log) amortized. This works because for each 2 iterations of Euclid's algorithm, one number is at least half of before and you use that number for the next iterations so the maximum number of iterations is O(log). Other than that, the number will obviously be divided at most O(log) times. Did I miss something?

        Edit: also, for your optimization my friend's reasoning applies. There will be 1 prime that will get below the exponent of B in one while iteration and it will disappear in the next one. So you get rid of at least one prime for each 2 iterations.

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

      Thanks riadwaw for this comment, he is right, this solution works O(nlog1.5M). Optimization is same as "divide as we can", but works faster because numbers are smaller. But I think that it doesn't make less complexity. Editoral will be updated.

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

        It actually does make the complexity O(logM) per case. Maybe I wasn't clear on the comment above. If you call gcd(q, b) for each 2 iterations b will be at least half so the sum of iterations until b is 1 is O(logb) (amortized).

        By iteration I mean iterations inside gcd

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

          Sorry, it's not clear to me why the complexity is O(log M) per case.

          If you have log(N) + log(N/2) + log(N/4) + log(N/8)..., that's still log(N)^2 time, no? Since it's log(N) + (log(N)-1) + (log(N)-2)... complexity.

          Seems to me like the real complexity is still . Since the worst case involves all the primes having different exponents, we can divide by more than half each time, we can divide by 2i for each iteration. So, our computation is log(N) + log(N/2) + log(N/2^3) + log(N/2^7)..., or log(N) + (log(N) -1) + (log(N) - 3) + (log(N) - 6) ....

          So, the number of log(N) operations we have to do is based off of how fast 1,3,6... reaches log(N). As that's just simply the triangle numbers, there's terms.

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

            If you had one gcd take x iterations then B will be <= B / 2^(x/2). So the complexity isn't log(N) + log(N/2) + log(N/4) + log(N/8)... and the sum of steps will be <= 2 * log(B).

            So if a gcd computation takes indeed log(B) or a big number of steps, the number will be much lower than B and the maximum number of iterations for the rest will be lowered. This is amortized analysis, not every gcd will be worst case. Also as you get closer to worst case for gcd, worst case implies that gcd is 1 and you don't need to continue so more iterations == B is much lower.

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

          If I'm not mistaken the following simpler code works in :

          b = gcd(q, b);
          while (b > 1) {
            q /= b;
            b = gcd(q, b);
          }
          return q;
          

          Suppose that the loop has several iterations, and the value of variable b in the i-th iteration is bi. Time complexity of the i-th invocation of Euclid's algorithm is . So the total complexity of the loop is , since for some Q.

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

solution for Div2. C (Div1. A):

https://math.stackexchange.com/questions/310402/proving-finite-vs-infinite-representation-of-p-q-in-base-b

(i think now there is no violation with codeforces stupid rules)

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

An interesting game

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

problem C looks trivial. Does this dp works? dp[i][pos][x1][x2][x3][x4]=minimum cost if the first i people already entered in the elevator, currently we are at floor pos, and the elevator contains people that wants to go to floors x1,x2,x3,x4.

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

This is the first round when I solved div1 E. I solved div2 E for the first time when Livace was the problem setter too (Codeforces Round #442).

Link: http://codeforces.me/contest/877/standings

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

in problem (B. Minesweeper) 1 1 * how test like this can be valid ????

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

During the contest I wanted to hack leon_ldy's solution(38273146).I had 2 unsuccessful submissions in this problem and after my second submission I noticed in pretests 8 , n=1.but why his submission passed pretest? this is his code:

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

const int INF = 0x3f3f3f3f;
const int MAXN = 1010;
int a[MAXN];

int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n);
	int j = n - 1, k = 0;
	while (true)
	{
		j--;
		if (j == k)
			break;
		k++;
		if (j == k)
			break;
	}
	cout << a[j] << endl;

	return 0;
}

but when n=1 so j=0. and in the "while (true)" we had TLE. because at first "j--" and after that j=-1. so always j!=k.

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

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

C+E = (Code*Code*Code+Code^2)^Code

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

For C I check whether the divisors of q are a subset of the divisors of b with gcd but still get TLE on 13.

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

Any ideas for D?

»
8 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +9 Проголосовать: не нравится
def gcd(x, y):
   while(y):
       x, y = y, x % y
   return x
a=input()
while(a>0):
    a-=1
    p,q,b=map(int,raw_input().split())
    r=gcd(p,q)
    q=q/r
    r=gcd(q,b)
    while(q!=1 and r!=1):
        while(q%r==0):
            q=q/r
        r=gcd(q,b)
    if(q==1):
        print"Finite"
    else:
        print"Infinite"

even after writing exactly the same code as it is being discussed in the comment section, my solution failed. Time limit for python is too strict. i got tle in 11. Please verify if there is a mistake on my side or this happened because of the language selected. Thanks :)

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

Is the time limit for python and c++ same every time for every question???

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

For Div2D , if (r-l+1) is power of 2 then we can take all elements from l to r.

If I am right then please someone say the answer of this input and how ?

24

1 2 128 256 512 1024 2048 4 8 16 32 64 1 2 128 256 512 1024 2048 4 8 16 32 64

1

5 20

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

During the contest I had the following problem. In my template I have a few pragmas that should optimize operations and make Codeforces submissions faster (they’re pretty common to include nowadays).

However, for today’s problem E, something weird happened. The solution with these pragmas got RE verdict on pretest 1, while the solution without them got accepted.

http://codeforces.me/contest/983/submission/38296856 http://codeforces.me/contest/983/submission/38297301

I assure you the only difference between the two sources is in the pragma macros.

Have you ever experienced something like this? What pragma do you think is broken, in this sense?

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

    Leaving my comment, cuz I am curious as well and I wanna be notified :D

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

    I tested on custom invocation and put the bits/stdc++ line before the pragmas and oddly it worked. I have no idea why

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

    Third pragma. The problem may appear in situation, when CF uses different machines with a different architecture to compile and run code. It's common problem on Yandex Contest system. I use following pragma for it:

    #pragma GCC target("sse,sse2,sse3,ssse3,sse4")
    
    • »
      »
      »
      8 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +1 Проголосовать: не нравится

      So, is it only the tune=native setting I shpuld remove or all the rest of them?

      Also, I can’t test myself right now, have you tried running it without tune=native and seen it work?

      Also, I see no point in using these pragmas outside CF, as from my experience with using it, it was always worse times.

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

        Ok, I tested. In your case it's "abm" setting.

        Also, I see no point in using these pragmas outside CF, as from my experience with using it, it was always worse times.

        Actually, It depends not on platform, but on problem and on your code. That is, if the bottleneck of your solution can be vectorized, then the pragma will help. Otherwise, the optimizer can apply vectorization where it is not needed, and your solution will slow down.

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

          I agree with that. However, I’ve seen consistently better results overall on Codeforces, while I’ve never seen improvements on Yandex (Opencup for example). I think it depends on the architecture and the compiler as well. I’m not pretending to know anything here, but my guess is that the running on Windows the pragmas will have a bigger positive impact than on Linux.

          Have you ever had noticeable changes using these pragmas on Yandex? (compared to not using them, obviously)

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

        abm changed the implementation of std::__lg, which is later called by std::sort. Here's a simple example of it being unstable, even on other platforms:

        #pragma GCC optimize("Ofast")
        #pragma GCC target("abm")
        #include <bits/stdc++.h>
             
        using namespace std;
             
        int main() {
            cout << __lg(1) << endl;
            volatile int i = 1;
            do {
                cout << __lg(i) << endl;
                ++i;
            } while (i <= 1);
        }
        

        Output:

        0
        31
        

        with abm

        without abm

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

        Also, I see no point in using these pragmas outside CF, as from my experience with using it, it was always worse times.

        Lol, I added the Ofast pragma to my code for E and it slowed down by ~50%.

        On the other hand, one secondary school student in our IOI selection used

        # pragma GCC optimize ("O3")
        # pragma GCC optimize ("Ofast")
        # pragma GCC optimize ("unroll-loops")
        

        to almost solve a problem with bruteforce.

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

The time limitation on Div2C is too tight.... just reassigning gcd value made it passed.. -_-

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

Systests for div1B are weak, i see some O(q*n) solutions accepted

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

Can anyone explain why first gives TLE and the other one AC 38300452 and 38300601

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

When are we going to get the tutorial?

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

So, did noone notice this: 1 2?

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

can someone explain why the first query of the second test case of Div.2-D is 60 instead of 63? shouldn't it be 1 ^ 2 ^ 4 ^ 8 ^ 16 ^ 32?

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

Pretests for B were pretty weak. In my solution I put a "n" instead of "m" in the second loop when I wanted to traverse my matrix. Apparently that was enough to pass the pretests. I noticed that error only after the system tests.

Then I changed "n" for "m" and got AC. Sad day for me :( .

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

Q. When does one grow up? A. When one reads more comments on CF than FB.

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

In div2 problem C For values of p,q,b=(10,5,3) in TC#3 how the answer is finite

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

    10 / 5 = 2 in base 10 which is 2 in base 3. This does not have a non terminating decimal part(rather does not have any digit after decimal point)

    I guess you are confusing with the case (p,q,b) = (5, 10, 3). In which case it would be non terminating and hence infinite in problem's context.

    So you only need to take into consideration the prime factors of denominator and base since for improper fraction a/b you can always write it as [a/b] (greatest integer function) + {a / b} (fractional part) where the former will always be translatable to different bases without recurring decimals . Refer editorial for more insights.

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

      Well if we convert both numerator and denominator firsthand to base 3 i.e. 10 in base 3 would be 101 and 5 in base 3 would be 12, so 101/12 will be infinite. I am confused here.

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

        Yes it is correct to say that but notice that since you convert numbers to base 3, conventional division(in base 10) does not work.

        You can still observe that base3(12) * base3(2) = base3(101). Hence we don't have a recurring decimal. An easier way to do the this is the same as mentioned in samples in the question .

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

I was trying to solve Div1E with O(n * sqrt(n)) complexity, sqrt(n) jumps instead of binary lifting. When I debugging I changed my sqrt variable to 1. And it got accepted.

38320734

It simply tries to jump lca and stop when there's a route from this node to lca. And same thing for second node, also check for ans - 1, no different solution.

You can check my code and see that for every query I'm calculating the answer with increasing res one by one.

while(!inside(c, go[x])) {
	if(go[x] == x) {
		res = -1;
		break;
	}
	res++;
	x = go[x];
}

And sad part is I have no clue how good my O(n * sqrt(n)) solution is. It actually got slower time :(