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

Автор chokudai, история, 6 лет назад, По-английски

We will hold AtCoder Beginner Contest 179.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

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

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

"We are looking forward to your participation!"

We are looking for quick editorials.

P.S. I love ABC's.

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

What are the ALC contests of Atcoder?

Edit: It's is described in this blog

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

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

I tried a DP solution for D. Somehow getting TLE in 6 TCs. I tried to optimize it as much as I could. Am I missing something?

Link to Submission

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

First time in ABC I was able to solve all problems. Here are short explenations.

F
E
D
C

Funfact, I had no WA, all AC on first submission.

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

How to solve problem D?

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

    I solved it without segment tree

    I used difference array. Time complexity of $$$O(N*K)$$$

    basically let dp[i] be no of ways to each i.

    Then you increment, $$$i$$$+$$$L_j$$$ to $$$i$$$+$$$R_j$$$ with dp[i], increment using difference array method, and keep summing as you move toward right.

    The answer would be dp[n]

    Submission

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

    I solved it maintaining a prefix sum array and using dp.

    dp[i] = sum of dp[j] for all j, i is reachable. As the range was contiguous it was easy to get the sum of dp[j] using prefix sum.

    My Sumbission

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

      could u plz explain more

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

        Here dp[i] is the number of ways to reach i.

        dp[i] was calculated by the sum of dp[j] for all j from where i is reachable. Assume i = 4 and i is reachable from 2 and 3. If the number of ways to reach 2 is 1 aka dp[2] = 1 and the number of ways to reach 3 is 2, dp[3] = 2 then dp[4] = dp[2] + dp[3] which is dp[4] = 3 (rule or sum)

        And for any i corresponding js were calculated from the ranges and their sum was calculated from the the prefix sum array. For any position iand a range L, R i is reachable from all valid i-R, i-L.

        Finally the answer is dp[n].

        Complexity O(N*K)

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

I got runtime error in sometest cases in prob D with segtree can somebody help me? https://atcoder.jp/contests/abc179/submissions/16889464

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
void test_case() {
	int n , x;
	cin >> n >> x;
	for(int i = 0 ; i < 2*x ; i++){
		int p;
		cin >> p;
		c.insert(p);
	}
	dp[1] = 1;
	for(int i = 2 ; i <= n ; i++){
		for(auto j : c){
			if(j <= i){
				dp[i] = (dp[i]%M+dp[i-j]%M)%M;
			}
		}
	}
	cout<<dp[n]%M;
}
 

what WA in my D https://atcoder.jp/contests/abc179/submissions/16888327[my sol link](http://https://atcoder.jp/contests/abc179/submissions/16888327)

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

It`s the first time I AK abc! LOL

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

I tried to solve D by repeating knapsack dp approach with time complexity O(N*m).But TLE destroyed my today's contest.Can anyone help me with that?

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

Eagerly waiting for geothermal's editorial.

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

Hello in D no I used the similar pattern of dp like CSES-Coin Combinations I. but get TLE from that.Isn't it the similar pattern problem.

My solution is here

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

Could anyone please explain the 1 testcase this is failing on? I have tried to find a cycle and then adding to the sum the sum of that cycle and then adding the rest seperately.Submission

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

how to solve D? someone with good explanation?

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

    You can use this dp: dp[i] means how many ways do you have to go to the i-th cell.

    Let's get an array of long long dp[2n]. First we fill it with zeros. Denote the sums[2n] as prefix sums array of dp.

    1. dp[n] = 1, sums[n] = 1

    2. for each cell from n+1 to 2*n and each segment (l[j], r[j]) we calculate: dp[i] = (mod + dp[i] + sums[i - l[j]] - sums[i - r[j] - 1]) % mod

    You can understand that part as: to get how many ways I have to go to the i-th cell, I should sum the ways from all dp[the previous one, from which you can get into this].

    The value sums[i - l[j]] - sums[i - r[j] - 1] gets us sum: dp[i - r] + dp[i - r + 1] + ... + dp[i - l]

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

how do you solve c? I got TLE my solution is only O(n^2)

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

I believe F can be solved using monotonic set

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

I have written an unofficial English editorial.you can find it here.

UPD: Added editorial for problem F.

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

    In the explanation for C : Could you please explain how the number of ways of choosing is N/A ?

    I have tried to do it on paper but couldnot come up with the intution.

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

      It should be $$$\frac{N - 1}{A}$$$ fixed it now, thanks for notifying me.

      The reason for that is for every $$$A$$$ there can be $$$\frac{N}{A}$$$ numbers for be such that $$$ A \times B \le N$$$, however we should subtract $$$1$$$ because $$$C$$$ can't be equal to zero.

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

Can E be solved with Matrix exponentiation??

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

I tried to solve E,but for some unkown reason,I got two RE.

Can you help me?

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

Editorial D

How to solve in O(nlogn) when the transitions cannot be written as a sum of small number of segments?

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

    [ignore this, too much complex]

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

    let $$$J$$$ be the set of possible jump lengths, now $$$ J = \cup[l_i,r_i] $$$

    Now we can use generating function $$$ G $$$ to define that set.
    $$$G = \sum_{i=0}^N c_i x^i $$$ where $$$ c_i = 1$$$ if $$${i \in J}$$$ else $$$c_i = 0$$$.

    Now, number of ways to reach from $$$1$$$ to $$$N$$$ using exactly $$$k$$$ jumps = $$$[x^{N-1}] G^k$$$.

    As there is no restriction of jumps,so we sum it over all possible $$$k$$$.
    so, finally what we need is $$$[x^{N-1}]\sum_{k \gt =0} G^k = [x^{N-1}]\frac{1}{1-G}$$$

    now coefficient of $$$ x^{N-1} $$$ in the polynomial $$$\frac{1}{1-G}$$$ can be easily calculated by calculating inverse of polynomial $$$ 1 - G $$$ restricted to max degree $$$N$$$.

    Overall complexity is $$$O(N\log{}N)$$$

    For calculating inverse of polynomial you can refer Operations on polynomials and series

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

ABC turning into AGC :/

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

In problem E , How can I know that the series will repeat itself?