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

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

We will hold AtCoder Beginner Contest 171.

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

We are looking forward to your participation!

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

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

Starts in 5min

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

I was just trying to cheer up.

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

I know this time E was actually easy, but the first time I solve E, I am unable to solve C, I'm so sad.

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

has someone solved d. can it be solved without segment tree

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

    Why to use chainsaw when work can be done with butter knife!

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

    Yes it can be solved without segment tree My approach

    1) Keep track of current sum of total elements

    2) Keep track of numbers of all the integers in array (i.e in array {1,2,1,3,1,,2,3,4} a[1] = 3, a[2] = 2, a[3] = 2, a[4] = 1. And current sum = 14.

    3) Than for each query update update the sum as

    sum = sum + (number of element in a[first number]) * (second number — first number)

    4) than change the array a at appropriate indices

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

    Segment tree is way overkill. It is actually quite simple. ARR[100005] stores the number of occurrences of each number in V[N] (V is the inital array given in the input). SUM stores the current sum of all elements. Then you encounter a query for example (1, 2). You know you should change all 1's into 2's. So just do S -= ARR[1] (coz 1's no longer exist). then S += ARR[1]*2 (coz all 1's are now 2's). And then ARR[2] += ARR[1] and ARR[1] = 0.

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

    Use Map

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

after contest ended,, can anyone provide the solution of C and E please.. I first-time attended and solved a,b,d. trying c and e for almost 50 minutes..

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

what is the logic for problem D

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

    Basically, keep a map which has the count of all numbers occurring in the array, and after each query, update the map. My submission-https://atcoder.jp/contests/abc171/submissions/14549573

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

Please don't ask contest related questions while it is ongoing

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

Quite good maths in $$$F$$$

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

how to update an element in map

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

trying problem F for more than 40 mins.. can't get anything.. even cant get the testcases ... anyone after the contest please help me for problem F with detailed explanation and how to arrive to such solution

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

C is a popular interview problem with different name. https://www.geeksforgeeks.org/find-excel-column-name-given-number/

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

E and C should have been swapped ):

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

Is F 26 ^ (k + s.size()) - number of strings of length k + s.size() that doesnt contain s as subsequence? How to get second value? I guess dp of O(n * 26) or O(n)? Halp me plzzz :(

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

Super quick editorial in Python. More editorials at http://interview.solutions

A.

A tutorial
A code

B.

B tutorial
B code

C.

C tutorial
C code

D.

D tutorial
D code

E.

E tutorial
E code

F.

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

Fs statement would have been more clear if distinct strings had to be counted.

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

How to solve F please help

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

Can anyone help me with the problem F? I can feel there is a lot of maths involved (possibly). Is there any simple way?

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

Today's problem C is a subset of problem 1B

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

I've posted an English editorial here: https://mirror.codeforces.com/blog/entry/79153

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

It was my first atcoder contest only able to solve problems a,b,d. Looking forward to solve more in upcoming contests.

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

that was my first atcoder contest and I couldnt solve C. Are there editorials after contests?

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

Nice contest.

How to do F?

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

How to solve F ?

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

can someone tell logic behind on how to solve C?

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

I firmly believe that I'd seen the E in some last year's Codechef cook-off.

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

IMO, this contest was much easier than other ABCs. How to solve F?

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

What is the problem in solving D using a dictionary? I got 8 AC and 4 WA Code: https://ideone.com/BWSxtc

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

What is the solution for F? I tried to solve it with combinatorial but I failed. Any theorems?

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

F can be solved using this link.

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

My approach for F was to calculate the number of ways to put K indistinguishable objects in |S| + 1 containers (the objects being the new characters and the containers the spaces between letters, here with |S| I denote the length of the string) and then choosing one letter for each new character. Resulting in $$$\binom{K + |S|}{|S|}\times{26^{K}}$$$. However, it didn't turn out to be right... can someone help me?

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

how to solve F?

Any sorts of hints are appreciated.

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

Can someone please explain on which test case my submission failed for the problem D. I used the same approach as in editorial. https://atcoder.jp/contests/abc171/submissions/14558518

»
6 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится +64 Проголосовать: не нравится
F's solution
»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I thought of F like this: Let the length of the string given=N So, the final length of the string (to be formed) must be N+K Now, consider all the strings that can be formed of length N+K. This will be 26^(N+K) Now, we know that the original string must be a subsequence of the final string. So, the problem reduces to finding the number of ways of having the given string as a subsequence of the final string. So, we need to fix N positions from N+K with the letters of the given string. So, the ans = 26^(N+K-N) * 1*(C(N+K,N)) = 26^(K) * C(N+K,N) However, I was not getting the correct answer to this approach. Any ideas as to why this might be wrong.

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

Can anybody explain a shorted method for question E? I could solve it but my method is a bit overkill?

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

hai everyone.. why my code give wa on D..

this is my code

pls help me.. thank you

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

.

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

Can anyone Explain Problem C

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

I think, Atcoder should not give WA, if my code does not give right output in Test 1, just like codeforces. I received a penalty in A, just because I took test cases as input

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

I think F is a very nice problem. The technique which is used for not to overcount any string is a genius idea.

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

Can someone please tell me where am I wrong in C. It is showing WA for some test cases.

#include <bits/stdc++.h>
using namespace std;

void solve()
{
    unsigned long long int n;
    cin >> n;
    string ans = "";
    while (n)
    {
        string a(1, (n % 26) + 'a' - 1);
        ans.insert(0, a);
        n /= 26;
    }
    cout << ans;
}

int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

In cpp.If anyone need .

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

Video solution for problem F.

Link: https://youtu.be/3mnwcJGO_MI

UPD: sorry for uploading this video that late, it's because of slow internet connection.

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

Can anybody give a comparison of difficulty between CF and AtCoder? Like what is the difficulty of AtCoder Beginner A,B,C,D,E in terms of the difficulty on CF?

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

chokudai I want to point out a bug in the AtCoder's Virtual Contest system. I registered for this contest but didn't participate. So, I decided to do a virtual for this contest after it ended. But on viewing virtual standings, it shows only my contest participation by default, in which I didn't try any problem.

This is a screenshot of virtual standings during my VC participation:

Maybe this can be updated to show the virtual rank instead of the contest ones, in case someone is writing a VC for the contest

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

for c

why is this solution is wrong. please clarify someone.

https://atcoder.jp/contests/abc171/submissions/14552303

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

Can anybody explains why in problem F, we have to multiply by 25K−(the number of letters before SN).

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

vedio editorial for all problems : https://youtu.be/eTKfAdpP1Cc

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

Can anyone explain problem E: Red Scarf?

I can't understand Japanese editorial...

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

Can anyone explain Problem F?

I can't understand the editorial's explanation...

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

Similar (But harder) idea for problem F:

Let $$$f(i, j)$$$ denote the number of strings T of length i in which the longest prefix of given string S which appears in our T as a subsequence is equal to j.

Then it's quite straightforward to reach the following recurrence:

$$$f(i, j) = f(i - 1, j - 1) + 25 * f(i - 1, j)$$$

(There is just one character available to increment the value of mentioned prefix of S. And 25 characters which don't increase the value of j).

The rest is just like the editorial. It was easier for me to reach the intended solution this way.

Actually this gives the idea to solve recurrence:

$$$f(0, 0) = 1$$$
$$$f(i, j) = a * f(i - 1, j - 1) + b * f(i - 1, j)$$$

In logarithmic time with linear preprocess (Read the editorial for F):

$$$f(i, j) = {i \choose j} * a ^ j * b ^ {i - j}$$$

Note that this is not true for problem F of this contest, because the value of j is at most the size of S, and there are some other constraints to reach state (i + 1, j + 1) from state (i, j).