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

Автор awoo, история, 2 года назад, По-русски

Neapolis University Pafos

Привет, Codeforces!

Благодаря поддержке Neapolis University Pafos, продолжается серия образовательных раундов. Университет предлагает получение степени бакалавра в области компьютерных наук и искусственного интеллекта со стипендиями JetBrains. Получите передовые навыки в области искусственного интеллекта и машинного обучения, которые подготовят вас к востребованным техническим карьерам. Любопытно? Ознакомьтесь с учебной программой прямо сейчас. Доступно ограниченное количество стипендий. Не упустите свой шанс учиться в Европе бесплатно!

Ищете способ улучшить свои навыки и увеличить шансы на получение стипендии? Присоединяйтесь к бесплатным клубам для старшеклассников от JetBrains:

В 14.10.2024 17:35 (Московское время) состоится Educational Codeforces Round 170 (Rated for Div. 2).

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 или 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Иван BledDest Андросов, Александр fcspartakm Фролов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Данный раунд частично пересекается по задачам с квалификационным этапом Чемпионата Юга и Поволжья России. Если вы участвовали в этом соревновании, то воздержитесь от участия в раунде.

Удачи в раунде! Успешных решений!

UPD: Разбор опубликован

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

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

It feels really good to be the first comment

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

Score distribution ??

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

How much +(Plus) will I get if I solve 3 problem in 1H...

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

How much +(Plus) will I get if I solve A-B-C within 1H??

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

Two contest on same day for me.

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

Why the recent Educational Rounds were removed from Harbourspace?

I thought that there had been a logo on the top-left of the page.

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

Two contests on my birthday! Cool!

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

As a problem writer, I feel it is important for me to mention that problem D is going to be an interactive binary search tree problem.

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

Well what's the score distribution? Can you please update the post and add score distribution?

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

Hope to become pupil after this round :p

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

Last night/Early Morning contest Messed up my sleeping pattern. I desperately want to participate, but at the same time my mind is sleep deprived.

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

I solved D but not able to solve B and I end up with 7k rank.

I won, but at what cost?

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

    How did you do D?

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

      Lets do DP. Let N be the number of 0's.

      Define dp[i][j] as: we are at the ith 0, and we already have j intelligence points.

      Now the current point can be an intelligence point or a strength point.

      If we take intelligence point, we will have (j + 1) intelligence points and i — 1 — j strength points. Now find how many rounds you can win (you can do this by storing the positive and negative numbers from current 0 to next 0 and upper_bound over it).

      So the transition becomes dp[i][j + 1] = max(dp[i][j + 1], dp[i — 1][j] + wins)

      Or if I take the current 0 as a strength point, we will have j intelligence points and i — j strength points. Again find how many rounds you can win (same way as before).

      Again, transition is dp[i][j] = max(dp[i][j], dp[i — 1][j] + wins)

      Finally, ans = max(dp[last_0][intelligence_achieved])

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

        can you explain how you calculated wins in more detail please?

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

          First, for every ith 0, store all the positive and negative numbers from ith 0 to the next 0 in a list. Call it cnt[i][0] for positive numbers and cnt[i][1] for negative numbers (take absolute value of the negative numbers and store)

          Later, when you do DP, at ith 0, if you have x intelligence points and y strength points, you can upper_bound over cnt[i][0] for x and see how many rounds you can win. Same for y, upper_bound over cnt[i][1].

      • »
        »
        »
        »
        2 года назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится
        I implemented the same idea but it failed on test case 18 my answer was +1 wrt to the original, can you help me debug, please?
  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    you needed to observe the pattern, took 30 mins away from my clock :(

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

what is the soln for D ? i tried DP but TLE'd 285921797

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

I was thinking about this problem when solving F, but F has multiedges Even Outdegree Edges

Upd: easy to adapt and worked for this F too, almost the same code I made for the above problem, just try to define the direction greedily in DFSTree, if outdg is 1 for the current node, change edge to its parent and update the outdg of parent node. if orientation is 0, then choose xi, else, choose yi. 285931982

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

my m^2logn dp TLEd in D. bruh moment

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

O(n^2) can't pass Problem D easily and need exhausting optimization. Time limitation tooooo strict.

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

[https://oeis.org/search?q=1+2+1+2+4+1+2+4+8+1+2+4+8+16+1+2+4&language=english&go=Search]

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

What's the intended time complexity for D? My O(m^2logn) passes.

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

https://codeforces.me/contest/2025/submission/285927740 anyone knows why this TLEs? i saw some people doing the same thing :(

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

I tried to make an vector of vectors srs where all the continous segment are present and did the sliding window to check the max I can pick with k distinct, can any one point out where Its failing. thanks

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

I think submissions should be rejudged for D with less strict bounds if O(m^2logn) cannot pass... Even my O(m^2 + mlogn) code barely runs under the time constraint...

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

Was about to get excited until Wrong answer on test 8 on D, well fml then I guess

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

In problem E, I wrote the solution such that:

I started on first suit and define if I take first j cards, so number of ways if C(m, j) * ways[m — j][(m — j) / 2] which ways[i][j] is number of ways to divide i element to 2 parts

When I took the transition of the dp, on next suit, if I had j cards from first suit, I can use x of them to beat any x cards so I have to mul C(m, x) * ways[m — x][(m — x) / 2]

So the transition of f[i][j] from i to i + 1 is: f[i + 1][j — x] += f[i][j] * C(m, x) * ways[m — x][(m — x) / 2]

Did I make a mistake ? I can't find

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

question B is cancer, Took 45 minutes to just guess 2 power k.

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

explain E clearly please :(

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

explain E clearly please :(

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

How to solve E?

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

    I think it is dynamic programming. dp(suit number, remaining cards of suit 1). then you just have to solve the one dimensional problem for a specific suit number. This is rough idea, still haven't solved it. This should solve it in O(N^2M) time complexity I believe.

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

      I treated the one-dimensional case as a balanced bracket sequence (there can't be a prefix where player 2 has more cards), then the transitions are basically counting balanced bracket sequences with fixed prefixes which is a known problem

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

    Maybe I need to explain why n = 3, m = 6 's result is 1690 :(

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

    Consider one suit. Define $$$a_k$$$ is the number of valid ways such that the difference between the number of cards of two players is $$$k$$$. You can use either dp or combinatorics to solve this. Note that player 1 must have no less suit 1 cards and no more suit X cards than player 2, so we have $$$k_1=\sum_{i=2}^nk_i$$$. The number of ways for the other suits is a convolution of $$${a_k}$$$, and given $$$n,m\le500$$$ you can use either brute froce or NTT.

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

      Detailed. Thx.

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

        Okay finally I solved it.

        You can see that if on the first time, you have x cards with suit 1, then when you go from suit i to suit i + 1, if you have to "pay" j cards suit 1 to beat j cards on suit i + 1, so the transition is f(i, x) ----> f(i + 1, x — j)

        Let's define ways(i, j) is number of ways when you have i cards and after distributing, the number of cards in first set more than the number of cards in second set j ones. I define j is the different between number of cards in first set to number of cards in second set because j is "free", you can use j to beat another cards

        The formula of ways(i, j):

        ways(0, 0) = 1, ways(i + 1, j — 1) += ways(i, j), ways(i + 1, j + 1) += ways(i, j)

        the formula of f(i, j)

        f(1, j) = ways(m, j)

        if we use x of j cards to beat x cards which suit i + 1: f(i + 1, j — x) += f(i, j) * ways(m, x)

        Final result is f(n, 0)

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

          In fact, $$$f(i, j)$$$ can be seen as $$$ways(i, j)$$$.

          You can solve it bracket match. The first player's cards are (s, the second player's cards are )s. For suit 1, each prefix must satisfy (s are no less than )s. Now $$$f(i, j)$$$ means that we concider first $$$i$$$ suit 1 cards and the first player has more $$$j$$$ cards than the second player. So the fisrt part is as you said.

          Let's see how it works on suit $$$2 \sim n$$$. We know that each suit satisfies the second player has each suit no less than the first player. If $$$f(i, j)$$$ means the first $$$i$$$ cards (s match )s, and the second player has more $$$j$$$ cards than the first player. Note that if we replace the excess (s to )s, it's completely identical!

          So for suit $$$2 \sim n$$$ cards we can use convolution. Let $$$g(0, x) = f(m, x)$$$, calculate $$$g(i, k) = \sum_{x + y = k}g(i - 1, x) \times f(m, y)$$$. After $$$n - 1$$$ rounds, $$$ans = \sum_{i = 0}^{m} f(m, i) \times g(n - 1, i)$$$. Because the more $$$i$$$ )s should be matched by $$$i$$$ (s.

          Here's my submission 285980588.

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

            This is an interesting solution, can you tell me where to learn more about the concept you mentioned towards the end?

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

              Oh, we refer to this form $$$h(k) = \sum_{k = x + y} f(x) * g(y)$$$(* can be any operator) as the convolution. It has the same form as normal convolution. Because it is $$$O(n^2)$$$, an algorithm can solve this form with $$$O(n\log{n})$$$, like NTT and FFT. Generally speaking, in this problem we don't need to use NTT or FFT, because $$$n \le 500$$$, $$$O(n^3)$$$ is enough.

              As for what I mentioned at the end is to multiply many of the same things together. We consider $$$g(i, k)$$$ means that, for first $$$i$$$ suits the second player has more $$$k$$$ cards unmatched. $$$g(i, k) = \sum_{x + y = k}g(i - 1, x) \times f(m, y)$$$ means the $$$i - 1$$$ state how to recursive the next state. Because for first $$$i - 1$$$ suits the second player has more $$$x$$$ cards unmatched. For $$$i$$$ suit the second player has more $$$y$$$ cards unmatched. Then for first $$$i$$$ suits the second player has more $$$x + y$$$ cards unmatched. This is why it comes up.

              Note that convolution is just a form of calculation.

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

Memoization gave TLE on D :(

converted into iterative soon after contest got over :(

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

I don't even get that D is a dp problem lmao, 1hr on the problem and I don't have a single clue. I need to do more dp exercises

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

I think the submissions for Problem D should be rejudged... My O(m^2logn) solution did not pass, and even after rewriting to O(m^2+mlogn) it barely passes...

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

285925069

Why is this giving TLE? (C)

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

If you complaint about the tl in D being too strict, that probably because you lack proper optimization skill lol https://codeforces.me/contest/2025/submission/285928139:

1) The most efficient data structure to store data is the one that has all the memory as close as possible: an array/vector.

2) If you ever use a 2D vector to store the dp, you have to wonder if you can optimize it to 1D. This is a huge leap, not for the memory, but for one important thing: Cache.

You can see my submissions for thought process

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

Great problem set!

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

For problem D

My first solution had used an ordered set for the splitting the indices into segments and storing in a sorted order which gave me a TLE. The TC for the solution should be O(m^2logn) as to my knowledge please correct me if I'm wrong. 285893834

Code

I used the exact same logic but replaced the ordered set with a vector and sorted the vectors and used upperbound for my final submission which should be of the exact same time complexity and got AC. 285923230

Code

Could anyone help me out in understanding why is it so that upper_bound solution works but set doesn't?

I tried to use the same logic with a regular set and had the same issue. Adding the else if(abs(x)>cnt) continue; line in the ordered set solution did not work which is the bit of logic changed in both the implementations.

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

In E, I just didn't realize that in a suit i(>1) 1st player can't take extra card when the current state of suit is already a tie (assuming we select the card from small to large in the suit). Since all previous card matched with a 2th player's card, if 1st take this card, it cannot beat any card (but you cannot let this happen, it will leads to the lose in global).

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

G is cool

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

    How to solve G? I see, that the answer is $$$\sum{a_i} + \sum{\min{(a_i, b_i)}}$$$, where $$$a_i$$$ are heroes and $$$b_i$$$ are artifacts, and they are matched greatest-to-greatest. Is it some well-known problem?

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

      I don't think it's a well known problem, this is the first time I encountered something like this. Took me a while to came up with the solution during the contest.

      My solution uses:

      Your observation about the answer is correct btw.

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

there seems to be some issue. On "Standings" page, even after un-selecting the "show unofficial" checkbox, contestants having rating greater than 2100 are included in the ranklist.

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

nvm

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

Anything wrong with this solution to E, or just python tax? Runs in about 10 seconds on my machine. 285917083

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

TC is super strict on D. I think it cost me to write my own bsearch and use extra variables within the dp function (recursive of course). I kept debugging thinking there's some way to optimize further, but I'm just dumb. My brain during the round:

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

Solution of D in O ( M * M ) using prefix sums !

285955590

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

guys, why it isn't rated for me?

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

I was randomly checking other people's submission and came across This Submission . This code fails for the following testcase:

16 1
0 1 1 2 2 2 1 2 2 1 1 1 1 1 2 2 

Correct Output: 8

Actual Output: 0

Can someone explain why this code was Accepted?

UPD: The author of that code told me that, the continue statement used in his code caused it to fail in my given testcase.

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

Dp_forces

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

Tabulation DP worked in D, recursive gave TLE, same logic in both.

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

Are there a system test soon?Or I'll get my rating later?

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

Can anyone tell me why "re on test8"

285930355

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

I solved two questions in yesterdays contest , A and C

both of them showed as accepted during contest

but now its showing that only A has got accepted and submission of C is showing as "In Queue"

Can please anyone explain it?

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

Problem E1 and Problem E2: I saw the tutorial done using number of connected components. But does this handle the case of impossible?

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

Problem D recursive dp submission 285916779 2499ms I submitted anathor solution with vector inplace of array dp

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

Problem C: Why did i get TLE test 10?

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

When will rating get changed???

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

Why I get 1900,but still have a blue title?

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

Published explanation to Problem E (which I haven't solved in time, but shortly after) https://codeforces.me/blog/entry/135152

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

I submitted solution 285915907 in a contest which shows accepted during the contest and now it is showing runtime error on test 8. When I resubmit the same solution it shows it as accepted.Can anybody please help me out

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

    It seems to me, you search for lower bound in vs[-1], when indx = 0

    // Fill DP table iteratively
        for(ll indx = m — 1; indx >= 0; indx--){
            for(ll intel = 0; intel <= indx; intel++){
            	ll str=indx-intel;
                ll cti = lower_bound(all(vs[indx-1]), intel + 1) - lower_bound(all(vs[indx-1]), 1);
                ll cts = lower_bound(all(vs[indx-1]), 0) - lower_bound(all(vs[indx-1]), -str);
    
    • »
      »
      »
      2 года назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Thanks, but don't how it got accepted

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

        Well, it's undefined behaviour. Given that index = intel = str = 0, this two lines look like:

        ll cti = lower_bound(all(vs[-1]),1) - lower_bound(all(vs[-1]), 1);
        ll cts = lower_bound(all(vs[-1]), 0) - lower_bound(all(vs[-1]), 0);
        

        Compiler might optimize this code, checkin the conditions that arguments to the function are the same, and not perform lower_bound calculation and subtraction at all (less likely).

        Or, more likely, lower_bound from a location in memory that is garbage pretending to be a vector, yields some result, which is garbage, but consistent for the same arguments of lower_bound. So you get your cti = garbage — garbage = 0

        Until at some point, lower_bound(all(vs[-1])) fails because you try to attempt some restricted area of memory

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

Can someone help me understand why this got hacked for TLE? 285966035

I'm assuming there's something python specific which I'm doing inefficiently, but I'm not sure what.

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

    You should use pow(a, b, mod) instead of (a**b)%mod.

    This explanation might be wrong, but my assumption would be that in (a**b)%mod, since a**b can get giant, it's slow to work with and leads to TLE on larger test cases. When using pow(a, b, mod), the number stored internally in the pow function never gets above the modulo value, so it isn't as slow to work with

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

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

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

Hello 2025! Happy New Year!