atcoder_official's blog

By atcoder_official, history, 6 months ago, In English

We will hold AtCoder Beginner Contest 430.

We have updated the rating system. As these changes will apply starting with this contest, please see this post for details.

We are looking forward to your participation!

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

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

We finally get to use the new judge!

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Truck Driver ran over my logic, my confidence, and my will to continue.

»
6 months ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

The problems are generally good and all, there were no critical issues in the problems, except for just one thing...

I am very curious what they were thinking while preparing problem E...

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E<<<(a,b,c,d)

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

What G states: Find the maximum number of elements among $$$S_i$$$...

What I read: Find the maximum elements among $$$S_i$$$...

Therefore, I deserve yet another failure to gain 1 dan.

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

100

»
6 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

E should be used to teach string matching algorithms and not for a contest.

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Personally, C was logically easy but hard to code nice contest though

»
6 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Can we solve F by creating a directed graph for nodes 1 to n and finding the number of topological sortings possible?

»
6 months ago, hide # |
Rev. 2  
Vote: I like it +8 Vote: I do not like it

https://atcoder.jp/users/hyx_xingxing

This guy, gets rk43, I think he used AI.

D: https://atcoder.jp/contests/abc430/submissions/70616970

F: https://atcoder.jp/contests/abc430/submissions/70619227

He only used 8 minutes to write 1904 Byte.

And G: https://atcoder.jp/contests/abc430/submissions/70622170

He only used 12 minutes to write 4478 Byte! How can a normal man do that? And his code seems like AI, too.

Sorry for my weak English : (

And I find lots of new users that use AI to get a high rank, these people ruined our competition experience. A question to those AIers: If you use AI, it means you have already been replaced by AI. And once replaced, how will you live in an even more intelligent future?

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

    Personally, this does not look like AI code to me. Also being a new account and performing well does not mean someone is cheating. Many people practice in their local OIs before doing online contests.

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

    You know people just copy those templates instead of writing it from scratch, right?

»
6 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Do you also hate it when some big segment tree beats code doesn't work for some reason and the only test which might give you a glimpse of what could be wrong has $$$n, q \ge 20$$$?

Well I don't have any advice for that! Now I even think that STB doesn't work in this problem but can't understand why

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

G looks really interesting. Any hints please? Is lazy segment tree wrong (I think yes, but idk)? Would some sort of sqrt rebuilding work (again, I think yes, but idk)?

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

G

Knowing this makes solving $$$G$$$ easier, just have to extend for max and count Submission

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

After how much time rating is updated now ? When I used to give contests on atcoder 1 year age, then it used to get updated in just 20-30 mins. But till now it didn't.

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

    It usually takes atcoder about an hour to update ratings these days but now I can see my new rating already.

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I solved E using a hash algorithm, is there a better algorithm?

»
6 months ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

G can be solved in $$$O(Q \log N + N + \max x)$$$ time with $$$\max x$$$ std::sets and one lazy segment tree.

The lazy segment tree maintains the number of elements in each set and supports queries on the max and frequency of max. Separately, for each $$$x$$$, maintain a std::set $$$is[x]$$$ of disjoint active intervals of sets containing $$$x$$$.

On an add update, add the interval $$$[l, r]$$$ to $$$is[x]$$$, with additional updates to keep the intervals in $$$is[x]$$$ disjoint. Propagate all these updates to the segment tree: whenever an interval $$$[l, r]$$$ is added/removed to $$$is[x]$$$ (corresponding to updating $$$S_l, \dots, S_r$$$) add $$$\pm 1$$$ to $$$[l, r]$$$ in the segment tree.

Removal updates are similar. On queries, query the segment tree.

https://atcoder.jp/contests/abc430/submissions/70628647

(KACTL IntervalContainer is really nice here, just modify it to update the segment tree)

  • »
    »
    6 months ago, hide # ^ |
    Rev. 4  
    Vote: I like it +8 Vote: I do not like it

    Wow, this is a very cool solution. Maintaining the active intervals separately from the actual segment tree is really smart.

    PS: The fact that you can bound the number of operations by $$$O(q)$$$ because you can only make $$$2$$$ new segments per operation (one in case of partial intersection, one because of the new addition) is subtle but also nice.

    Edit: My implementation of this idea: https://atcoder.jp/contests/abc430/submissions/70633235

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

i love this contest :)

The difficulty level is moderate; it would be even better if there were number theory problems included.

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E was just there for the sake of it

»
6 months ago, hide # |
Rev. 4  
Vote: I like it +35 Vote: I do not like it

Hello, my account on atcoder simply disappeared. I had an account called Settop. I was doing the ABC today and after the contest, I was browsing the standings page on the website. At some point, my account logged out, and I tried to log in again, but I couldn't: it said the password and username were wrong. So, I used the "Forgot my username" option. When I entered my account email, it sent a message saying there was no account for that email, but I'm sure that was the correct email; I even have a screenshot. Then, using the same email, I created another account and checked the standings to see if I could find anything about the account, but it was simply gone. I hope I can recover my account. Can someone help me please?

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I found a O(n logn) solution to problem D, but it gives TLE on test 8. I don't know why can someone explain?

https://atcoder.jp/contests/abc430/submissions/70631585

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

    The Problem lies in this two lines in ur code:

    q.insert(q.begin()+ind, x);
    dist.insert(dist.begin()+ind, d);
    
    Why
    • »
      »
      »
      6 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      ok i solved same problem with iterators and it passed. tysm!

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

        it can also be solved with a combo of 2 pointers with sliding window and binary search. 1) find a window with exactly A a and less then B b. 2) find the most right possible R with a binary search over a prefix sum array 3) increment L

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I tried to solve C using dp, where dp[i] = dp[i-1] + la — lb + 1, if (la > lb). There are other cases too, but this is the core recurrence. Did anyone try a similar or any DP approach for C? Did you AC?

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

    Forgot to mention la is the largest index less than i such that [la,i] contains A number of 'a's and b is the largest index < i such that [lb,i] contains B number of 'b's, ie [lb+1,i] contains less than B 'b's.

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

      when you solve a problem using dp[i] = dp[i-1] + (blah blah), and you print dp[n] in the end, your answer is basically the sum of (blah blah) for every index. if you create a int res = 0, and then (res += la — lb + 1) for every index, you get the same solution. so your solution is just like the usual O(n logn) solution (i solved it the same way btw)

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

      really nice solution but this is just not called DP

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

      That's not DP though.

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
ll kmp(string&s,string&t){
    string temp=t+'$'+s;
    ll n=temp.size();

    vll lps(n,0);

    rep(i,1,n){
        ll prev=lps[i-1];

        while(prev>0 && temp[i]!=temp[prev]){
            prev=lps[prev-1];
        }

        lps[i]=prev+(temp[i]==temp[prev] ?1:0);
    }

    // for(auto it:lps) cout<<it<<" ";
    return lps.back();
}
void solve(){
    string s,t;cin>>s>>t;
    ll fir=kmp(s,t);
    ll sec=0;
    ll ans=s.size()-fir;
    while(fir<t.size()){
        if(t[fir]!=s[sec]){
            cout<<-1<<endl;return;
        }
        fir++;sec++;
    }
    cout<<ans<<endl;
}

I can't seem to figure out why this should fail for problem E. Any help will be greatly appreciated.

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Does anyone know why the following solution for D gets TLE? Mycode

I think it's essentially the same solution as Solution 2 in the editorial. Any recommendations will be greatly appreciated.

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

    Never mind. I figured it out. We should use set.lower_bound(a) instead of lower_bound(set.begin(), set.end(), a).

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why is kenkoooo not working again on my computer?(Please do not downvote my comment if you don't like)

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can E be done using string hash? If so, what is the hash function?
I have tried the function of $$$h(A)=(\sum_{i=0}^{|A|}a_i\cdot 2^i)\mod 998244343$$$, where $$$A$$$ is the string. However, it got 21 WAs in AtCoder. Here is the submission link. Sorry for my poor English.