atcoder_official's blog

By atcoder_official, history, 2 years ago, In English

We will hold AtCoder Beginner Contest 353.

We are looking forward to your participation!

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

| Write comment?
»
2 years ago, hide # |
 
Vote: I like it -15 Vote: I do not like it

I think the problem G is easier than usual because of the point values.

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

hope get a positive delta

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

Hope to Solve ABC

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

ABC 353 may include:

  • Primes ($$$353$$$ is a prime)
  • Palindromes
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

hfhf

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

how to do E?

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

Nice C, D, E

»
2 years ago, hide # |
 
Vote: I like it -15 Vote: I do not like it

太难了!!!

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

Can someone help me find out this code get WA for problem G:

https://atcoder.jp/contests/abc353/submissions/53380216

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

    Changing solve() to the following makes it accepted:

    void solve(){
        for(int i=1; i<=n; i++){
            __int128 nleft=get(1, 1, m, 1, t[i]).fi;
            __int128 nright=get(1, 1, m, t[i], m).se;
            dp[i]=p[i]+max((__int128)-t[i]*c+nleft, (__int128)t[i]*c+nright);
            update(1, 1, m, t[i], {dp[i]+t[i]*c, dp[i]-t[i]*c});
        }
        cout << max((ll)0, (ll)*max_element(dp, dp+n+1));
    }
    

    The changes are that the for loop bound is n instead of m, and at the end take the maximum between 0 and the dp maximums to handle the case if it is better to not participate in any market at all.

»
2 years ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

Why this gives WA for F? Code

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

can someone please explain what should i do to stop tle in problem C .What should i study to no get tle in next rounds?

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

I added hints for G: Merchant Takahashi on CF Step

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

    Hi, amazing solution and explanation. I have one doubt though. While choosing the optimal position to the right of current index (say t), why are you checking for the max value in range [t,n-1] ? Shouldn't it be [t+1,n-1] ?

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

      $$$[t + 1, n - 1]$$$ will also work. But then you need to divide into 3 cases, Left, Right and the third case is when you go to a market from town $$$t$$$ to town $$$t$$$.

      But you can take advantage of the fact that distance between town $$$t$$$ and town $$$t$$$ is zero. So it can either be clubbed with the left half or right half. So both of these are valid.

      • $$$[0, t-1]$$$ and $$$[t, n - 1]$$$
      • $$$[0, t]$$$ and $$$[t + 1, n - 1]$$$.
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to G ? I tried to come up with CHT but it may not work cuz i don't know how to deal with t[i]-t[j] :(

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

    Define $$$dp[i]$$$ to be the profit when you end your journey at index $$$i$$$.

    Then, define $$$ldp[i] = dp[i] + c \cdot i$$$ and $$$rdp[i] = dp[i] - c \cdot i$$$.

    Then, $$$dp[t]$$$ would take contribution from prefix maxima of $$$ldp$$$ and suffix maxima of $$$rdp$$$. So a Segment Tree or Fenwick Tree suffices.

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

Whoa, so many people know about segment trees, it's crazy... after seeing so many ACs on G I expected it to have a simpler solution, but nope...

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it -8 Vote: I do not like it

    Tbh G was simpler than C to me. It could have easily been an E, considering it was quite literally just about implementing a segtree.

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

    Isnt segment tree somewhat basic? Specially without lazy propagation, it is a very common topic, a little bit more advanced than binary search. You can just learn to use it as a black box, it is easier to learn than dynammic programming, about the same level as dijkistra or fast pow IMO.

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

      Agreed, especially with Atcoder providing its AC library, they do expect the participants to be aware of its usage as a black box.

      If you recall, there have been problems at position E (out of 7 problems) in past ABC where the intended solution was segtree. See ABC340E : Mancala 2

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

      I reached high purple without ever using a segtree, and now many cyans casually use it. Blackboxing data structures in later problems is not the direction I want competitions to go in.

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

When I didn't AC Problem C,my brain be like:

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

Am I crazy or is double hashing really meant to fail on E? I solved it using trie in the end, but struggled with 3 tests failing my double hash.

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

C >> D , how to solve C ?

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

why is using 1E8 (link) instead of 100000000 (link) giving wrong ans. I submitted 6 different solutions for prob c all of them correct but used 1E8 and none passed

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

    If you convert to int as in (int)1e8 it should work. It's the double comparison that is giving you troubles most likely.

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

Can someone tell me why problem F got

$$$\Large\color{red}{\text{WA} \times 4}$$$
  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it -16 Vote: I do not like it

    Corner case for K=2 probably?

    2
    2 0
    6 0
    

    Answer is 3

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

      thanks, although my code gives the correct answer for this case :(

      My mistake is when a point is in a $$$1 \times 1$$$ matrix, i will let it go to a $$$K \times K$$$ matrix. But two points in the same $$$K \times K$$$ matrix like below case, it will give WA.

      5
      2 2
      3 3
      
      
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

If you want to build intuition for today's G (specifically the trick of splitting the $$$|.|$$$ operator in DP problems), you can attempt ABC334F : Christmas Present 2. I also created a video and practice contest for the same.

»
2 years ago, hide # |
 
Vote: I like it +48 Vote: I do not like it
sigma problemset
»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Join me laughing at myself for what is probably the most overengineered E solution possible boop

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

Really liked F, really disliked G.

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

You can check video editorials of E and G here

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

Its giving me TLE for C. PLease help me optimize the code

include

using namespace std;

int main() { int n; cin>>n; long long a[n];

for(int i=0;i<n;i++)
{
    cin>>a[i];
}

long ans = 0;

int i = 0;
int j = n-1;

while(i<j)
{
    ans += (a[i]+a[j])%100000000;
    j--;
    if(j==i)
    {
        i++;
        j = n-1;
    }
}

cout<<ans<<endl;

return 0;

}

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

    it's O(n^2) and n <= 1e5. btw you could also write this soln with 2 for loops why did you complicate it

»
2 years ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

Dislike F.

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

can someone please debug my submission for G? I'm not able to pinpoint where i'm going wrong, everything seems right on a high level. I'd really appreciate you taking your time for this

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it -8 Vote: I do not like it

    Maybe your mistake is when there are 2 markets in the same location one after the other, are you handling this correctly?

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

    When calculating $$$c*(y+1)$$$ you may have an overflow.

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

    You are mixing up the zero based indexing and one based indexing. Here's your almost correct solution, where I used zero based indexing for segtree as well as $$$|.|$$$ operator. After the fix, your code passed 55 testcases instead of just 14 testcase.

    The rest 18 testcases fail due to a completely different issue, which is obvious to me, but I'll let you figure out and debug on your own. If you are still not able to, feel free to ping on the thread.

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

      well i changed -inf to $$$-10^{18}$$$ and changed final answer to $$$max(0, max(dp))$$$ now it fails on last 2 tests only xD, no clue as to where they are failing

      Upd : Got AC now, changed $$$dp[y] = max({left, right})$$$ to $$$dp[y] = max({left, right, p + dp[y]})$$$. Thank you so much for helping me out!! (also i love cf step, great initiative!!!)

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

Can someone please help with problem E? My solution uses trie and got 41 AC, 7 WA

https://atcoder.jp/contests/abc353/submissions/53412393

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

I thin E is more easier than D. D->60min, E->15min

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

why no english editorial atcoder_official