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

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

We will hold AtCoder Beginner Contest 165.

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

We are looking forward to your participation!

UPD:

In Problem E, the constraints says N <= 100000, but it turned out that the inputs are made under the condition N <= 200000.

It was revealed that only 6 people were affected by the defect of the problem E constraint, and 4 among them were rated competitors. As the impact is very minor, contestants excluding the four are going be rated, and the affected four will also be rated after rejudging to get AC on their submissions.

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

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

2 ABC this weekend, what a time to be alive! Thanks a lot AtCoder team for making this quarantine more fun!

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

Did the start time just got extended by 5 minutes?

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

website crashed ?

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

site is not loading?

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

RIP

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

Site down?

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

Again 502 Bad Gateway :(

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

504 Gateway Time-out:(

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

Postponed for 5 minutes.

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

Start time extended by 10 minutes.

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

extended by more 5 min :(

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

Will they just postpone the contest by increments of 5 minutes until enough people go away and there is less load on their servers??

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

delayed due to inadequacy in problem

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

“The start will be delayed for 10 minutes due to an inadequacy discovered in the problem. I'm sorry.“

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

Here we go

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

C is too hard for C, imo.

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

How to solve C !

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

Honestly, I think it is not very wise to give such C and D in abc contest.

I am sure there a thousends(?) of possible participants not submitting any solution because scared by a hard C and a D full of corner cases.

Dont get me wrong, I think these are nice problems, but simply misplaced.

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

The English Commentary for Problem C and D is here

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

Can someone give a hint on E and F?

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

Why is my ternary search failing on one test case for D? :((

https://atcoder.jp/contests/abc165/submissions/12647186

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

Problem statement of C was so confusing.Can anyone explain it?

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

    You are asked to create an array a, of size N. You should place values in that array from 1 up to M. The array should be not decreasing.

    Then you get those quadrupels. If you put at position a and b values, so that the difference is c, you get d points.

    Try to find an array with maximum possible points.

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

How to solve F ?

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

All the people complaining about C being too hard. Is it possible that they didn't notice the constraints that array is in increasing order A[1] <= A[2] <= A[3]..... <= A[N]? Because I skipped it initially and thought for several minutes that total case are $$$10^{10}$$$ which was outside the time limit.

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

Solns/Approaches

  • A. Check every element

  • B. Observe that answer never exceeds 5000 (use log to check). We can loop until success.

  • C. Generate every possible combination. In python, we have combinations_with_replacement which generates exactly what we need

  • D. Observe that for $$$x \lt b$$$, $$$\lfloor x/b \rfloor$$$ is zero. We want to take $$$x = kb-1$$$. Also observe that taking $$$k \gt 1$$$ always make the answer worst. We take $$$x$$$ as $$$\min(n, b-1)$$$.

  • E. What we need is set of $$$(a, b)$$$s such that distance between $$$a, b$$$ never occurs twice. (Considering not only b-a, but we have to consider the other way. e.g, when $$$n = 10$$$, distance between $$$1$$$ and $$$10$$$ is 1 and 9. both should not appear again.)
    When $$$n$$$ is odd, take $$$(1, n), (2, n-1), \dots$$$. One can easily show that this is valid.
    When $$$n$$$ is even, take those values until we can't. (e.g, when $$$n = 10$$$, we take $$$(1, 10)$$$, $$$(2, 9)$$$ but not $$$(3, 8)$$$ since distance between $$$(3, 8)$$$ is 5 and 5 — repeated.) Then, discard one unused value and proceed. (e.g, after two takes, use $$$(3, 7)$$$ instead of $$$(3, 8)$$$, and $$$(4, 6)$$$.
    Submission : https://atcoder.jp/contests/abc165/submissions/12617571

  • F. Consider computing LIS length in $$$O(n \log n)$$$ time with DP and lower_bound. (without considering the actual values). When we do this, we discard what was in that spot (lower bound). Instead of doing this, keep those values by multiset or stuff like that. We traverse tree in DFS order, pushing values we meet in LIS-solving pattern but keeping values instead of throwing away. When we traversed all of it's subtrees, we erase value of the node from where we pushed. To do this we track the number of non-empty multisets and index we pushed each value in. Time complexity $$$O(n \log n)$$$.
    Submission : https://atcoder.jp/contests/abc165/submissions/12637543

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

    @gratus907 can you please tell how you came to conclusion for problem E?

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

      I thought it intuitively after some casework... and I tried to prove my thought (I mean, not rigorously, but like convincing enough to start writing code)
      As I've wrote, a case when two people meet twice is only when there exists $$$(a, b)$$$ and $$$(c, d)$$$ which $$$b-a$$$, $$$n+a-b$$$, $$$d-c$$$, $$$n+c-d$$$ has repetitions. Try some casework in $$$n = 8$$$, $$$n = 10$$$ to convince yourself with this statement :)

      I actually have nothing much to say as I did tons of caseworks on paper...:(

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

    You don't really need any multiset for problem F. Just change the value at lower_bound and remember what it was. After solving all subtrees and updating the answer just return the value to what it was. Submission

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

      Apparently yes.. I discussed this problem with my friend after the contest and he also said the same thing. I felt very dumb since he coded like 800 bytes while I coded more than 2000... lol
      I have no idea how I managed to think returning values by dfs tree and then thought something like "WOW I want vector<multiset<int>>" and started coding :(

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

I'm assuming some greedy strategy works for C. Can somebody please post their logic/solution? I filtered queries such that for each (a, b) indices pair — the optimal c for maximum d is known. For the array A[n], I set A[0] = 1. From here, I am confused about how to construct the rest of the array. I tried a couple of ways but there were always some cases not adhering to the rule.

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

It seems difficult orz

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

I think E is harder than F, as I'm not good at construction and pattern observing

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

Is this round a bit easier than before? I used to solve 4 or 5 problems but today I solved 6 within a short time. Well anyway the problems are still very good (like, you can solve D and E with about 300 bytes of code but you need to think a long while). BTW, I think C is a bit hard for C. Since DFS may be not very "beginner-friendly".

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

D one was way too easier than the C one

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

Check Same question ... I still missed it.. hard luck today.

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

F is an easier version of NA Southeast Regional 2019 problem G

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

Nice contest!

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

From stars and bars trick we get for C only 92378 states are there i.e ncr(10+10-1,10-1)

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

A. Oh, constraints are really small, let's just iterate.
B. Hm, it's exponential growth, I think max answer is not too big. Let's write and see (turns out max answer was in samples, but I didn't notice).
C. Hm, seems like a lot of states, no idea, let's read D.
D. Hmm, let's write bruteforce and see. Oh, it's always zero for multiples, ok, let's take multiple-1 if we can.
C. Hmm, maybe there are not too many states? Let's write bruteforce and see. Oh, it's really small, dumb me. (It's just C(n + m — 1, n))

E and F are nice, but quite easy.

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

Can someone explain the observation made in problem E.

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

in problem E: if i match 1 with n then 2 with n-1 and so on (m times) why is it wrong

I got WA with this approach in 9 test cases

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

Can anyone prove the running time complexity for the brute solution of C please?

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

    O(Q * 92378) because number of valid(non-decreasing arrays) arrays with n = 10 and m = 10 are 92378. You can calculate this with dp or with Combinatorics.

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

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

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

May someone help me debug F: LIS on Tree? I have done using binary search and dynamic programming. I have used 0-indexed dp. My submission: https://atcoder.jp/contests/abc165/submissions/12674946

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

How does the checker work in E? chokudai

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

I can't understand why my A solution fails Here's my code

k=int(input()) a,b=map(int,input().split()) if b-a+1>=k: print('OK') else: print('NG')

can anyone point out my mistake

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

why would I get WA for problem.E

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxn = 1005;
int main(){
    int n,m; cin >> n >> m;
    vector<pii> ans;
    int L = 1,R = n;
    while(m){
        if(L+n-R == R-L) L += 1;
        else{
            ans.push_back(pii(L,R));
            L++; R--; m--;
        }
    }
    for(int i = 0;i < sz(ans); ++i) 
        cout << ans[i].x << " " << ans[i].y << '\n';
    return 0;
}
»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +24 Проголосовать: не нравится

I believe the test files for the problem E were incorrect.
Instead of n <= 100000 , it should be m <= 100000 . If I write an assert statement for the value of n being less than or equal to 1e5, the verdict is RE, while for 2e5+2 it is AC.

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

Problem F:I have used LIS(nlogn) with B.F.S. but getting T.L.E......please help. https://atcoder.jp/contests/abc165/submissions/12695808

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

Here is my list of submissions.You can use that as reference.

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

Why are there different results when using GCC and Clang? There are 4 testcases that fail to pass, but my method has no problem. So I checked the official testcase and the input and output, and found that the final problem is that GCC and Clang have different results. I want to know why? ? ? ! ! ! here is my two submission:(the first is AC and the second is WA,but the code is exactly the same!) Your text to link here... Your text to link here...

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

    Wangxuelong, the defined arrays a,b,c,d should have length 51 if you intend to write into them at positions 1, ..., 50 — this causes your code to write outside of bounds of the arrays, causing undefined behavior (it can still theoretically work, but also the compilers decided to zero out all variables in your program, it would still be a valid thing to do according to C++ spec — the compiler is free to do anything it wants when you do out of bounds access).

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

For E detail explanation with examples and code check here

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

For E,can some one tell me why this is wrong: void solve() { cin>>n>>m; int now=1; for(int i=1;i<=m;i++) { cout<<now<<" "<<(n+now-i-1)%n+1<<endl; a[now]=1; a[(n+now-i-1)%n+1]=1; while(a[now])now=(n+now-1-1)%n+1; } return ; }