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

Автор kostka, 5 лет назад, По-английски

Looking for a way to stay connected, try something new, and have a little fun? The Kick Start 2021 season has begun!

Kick Start offers programmers of all skill levels the opportunity to boost your skills through a series of intriguing algorithmic and mathematical problems designed by Google engineers. Each round starts fresh, so give any one of our 2021 online rounds a try — or join them all!

Join

Prepare

  • View our tutorial video to learn more about the competition platform and some useful tips and tricks.
  • Practice makes progress! Try your hand at past problems and read through our FAQ if you have a question.

Connect

Be part of the #KickStart community by joining our Facebook Group to meet other participants, chat about past problems, and hear about the latest updates!

Questions? Reach out to kickstart@google.com.

We hope you’ll join us for some fun practice. What are you waiting for?

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

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

This may be a dumb question, but why are all participants less than 16 years of age not allowed to participate?

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

Can you please answer one thing? Does Google really hire people from Kickstart?

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

Just curious, why cannot residents of Quebec participate in the contest?

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

Nice round how to do C?

i did it with BFS but it gave me Memory limit exceeded

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

    It's a multisource BFS problem.

    The idea is once you get the original matrix, there is only one optimal matrix that can be obtained. So, you find that matrix using BFS => First, store the indices of all matrix elements that have the maximum possible number in the matrix(note that it is always less than 2e6), and then move to it's neighbours and keep doing the same thing!

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

      I just did this : traverse from maximum to minimum values

      Lets talk about a value v, then set its neighbours to max(value_neighbour, v — 1) I tried to do multinode bfs, I got WA

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

      I did multisource bfs but I got WA :( Can you spot an error here?

      My Code
      • »
        »
        »
        »
        5 лет назад, скрыть # ^ |
        Rev. 2  
        Проголосовать: нравится +13 Проголосовать: не нравится
        1
        4 4
        10 1 1 1
        1 1 1 1
        1 1 1 1
        1 1 1 9
        

        Correct answer: 93

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

    No need for BFS.

    You can just find for each cell lower bounds in each of 4 directions and set new value to maximum of those (and initial value). For example, going bottom and right you need to find maximum of value[i][j] — i — j. The solution code is actually very similar to problem B.

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

Cool problem D

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

Problem set was quite nice. Was able to solve till C only :(

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

Can anyone explain how to do Checksum problem?

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

can someone pls help me with problem C,

my code gave the wrong ans

include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){ int t; cin>>t; int nn = 1; while(t--){ int r,c; cin>>r>>c; vector<vector> g(r,vector(c));

for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>g[i][j];

        }
    }

    priority_queue<vector<int>> pq;
    vector<vector<int>> visited(r,vector<int>(c,0));
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            pq.push({g[i][j],i,j});
        }
    }

    int ans = 0;
    //cout<<q.size()<<endl;
    vector<vector<int>> update(r,vector<int>(c,0));
    while(pq.empty()==false){
        int x = pq.top()[1];
        int y = pq.top()[2];
        //cout<<pq.top()[0]<<endl;
        pq.pop();
        if(visited[x][y]==1){
            continue;
        }
        visited[x][y] = 1;

        int dx[] = {0,0,1,-1};
        int dy[] = {1,-1,0,0};
        for(int k=0;k<4;k++){
            int x1 = x + dx[k];
            int y1 = y + dy[k];
            if(x1<0 || x1>=r || y1<0 || y1>=c || visited[x1][y1] == 1 || (abs(g[x1][y1] - g[x][y])<=1)){
                continue;
            }
            pq.push({g[x][y]-1,x1,y1});
            if(update[x1][y1]==0){
                update[x1][y1] = 1;
                ans += g[x][y] - g[x1][y1] - 1;
            }    
            g[x1][y1] = g[x][y] - 1;

        }
    }

    cout<<"Case #"<<nn<<": "<<ans<<endl;


    nn++;
}



return 0;

}

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

Will Google be backfilling test data for old problems (GCJ and Kickstart), or will Google only be uploading test data for problems starting this season?

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

Guys, do you have any test cases for the "Checksum" task? I'm trying to find a bug in my solution, but without having a failing test case it's not easy. It's obviously passing Sample Input/Sample Output, but failing with WA on the Test Set 1.

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

Is it just me that my kickstart problem page is still showing "In Review" and not showing my final rank and I received a mail from Google to accept your participation certification but on that page also it is showing "No competition History".

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

Screenshot-2021-03-24-163857
Just in case someone isn't aware of it.

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

This problem from the Philippines' national olympiad is similar to Round A problem C; I do recommend anyone who's solved it to give it a try.

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

Thank you sir for the plagiarism check. My rank increased by 1000. Thank you so much.

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

Good luck to everyone in round D. If anyone somehow missed the reminders, the round is about to start in less than half an hour.

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

is it happening with just me ? my submission is still being judged for 15 minutes

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

There is a tremendous queue, Do something about it @google. Or the entire experience will be ruined.

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

Queue :(.

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

Its been 30 mins I've submitted B , didn't get verdict till now

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

Cancel the round if you can't fix the issue, it's irritating!

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

I want a penalty refund after the solution runs for more than 25 mins and returns WA. :')

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

Google giving Codechef vibes :(

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

Why wait for the queue? Just solve the next problem.

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

    What to do if you are not able to solve next problem ?

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

      Then pretend your current submission will fail, and try to find the error. If it afterwareds turns out your submission was ok you did not loose anything. And otherwise you can submit the corrected solution.

      However, this does not work good if you submit by trial and error, but that strategy does not work good anyways.

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

    Speaking from experience, it's very frustrating when you put a solution in queue for 20 minutes that you think will pass only to get WA, at which point you'd probably have to stop what you were working on and then go to debug it now.

    I agree a lot of it can be solved by a good mindset towards it (i.e. not caring about it too much and moving on to other problems), but at least for me it's harder to focus when I know one of my previous solutions might WA and I wouldn't know for a while, not to mention the frustration if it eventually does.

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

      Of course it is better to have a quick queue instead of a slow one. But that was not my question.

      A lot of comments in this thread read like "I had to wait for X minutes before beeing able to proceed...". That is not true.

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

Hey Guys, Actually I have a question on how if we dont have return statement if the function is declared as int fun(), it is giving runtime error. That too only on google's ide ? but not anywhere else ? You can see here

https://ide.geeksforgeeks.org/U707PgW7Co

This solution runs on all the ide's I have tried (gfg, codechef, codeforces, and local cmd etc...),it runs perfectly fine but not on google's where It gives RE. I wasted about 1 hour trying to find what the hell is wrong, but after 1 hour i was able to finally figure out that this is the issue. (i.e if we change the function int calc to void calc, it runs fine in google) But I dont understand why. Could someone pls help.

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

Intervals, Intervals, everywhere...

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

For the 2nd part of last problem if $$$P$$$ divides $$$A_i$$$ then no problem but when $$$P$$$ does not divide $$$A_i$$$ we know that $$$A_i-(A_i\, mod\, P)$$$ has some power of $$$P$$$ but how to find power of $$$P$$$ from another factor — $$$(A_i^S-(A_i\, mod\, P)^S)/(A_i-(A_i\, mod\, P))$$$ or may be can we prove it doesn't contain?

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

How to do Testcase 2 for problem D ?

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

    I used segment tree and lifting the exponent lemma.

    Essentially, you store the following information in the node, and disregard elements $$$ \lt p$$$:

    1. Sum of highest powers of $$$p$$$ dividing $$$a[i] - a[i] \% p$$$ for all $$$i$$$ in the range handled by the node.

    2. Sum of highest powers of $$$p$$$ dividing $$$a[i] + a[i] \% p$$$ for all $$$i$$$ in the range handled by the node.

    3. Sum of highest powers of $$$p$$$ dividing $$$a[i]$$$ for all $$$i$$$ in the range handled by the node.

    4. Number of elements for which the third point is 0.

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

    My solution is completely based on some patterns, that are found using brute force solutions.

    Our goal is to calculate $$$V(a^n - (a \bmod p)^n)$$$.

    • Case 1: if $$$a \lt p$$$, then answer is $$$0$$$.
    • Case 2: if $$$a \bmod p = 0$$$, then answer is $$$V(a) \cdot n$$$.
    • Case 3: if $$$a \bmod p \neq 0$$$, then answer is $$$V(n) + \max\limits_{a - p + 1 \leq j \leq a}V(j)$$$ .

    Above method will fail if $$$p = 2$$$, $$$a \bmod 4 = 3$$$ and $$$n \bmod 2 = 0$$$. So i handle that case manually.

    Overall I used 4 Fenwick trees to implement the complete solution.

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

Can anyone help me why this logic gives WA on problem C. I store all pairs {Ai,Bi} in a set. Then as we get the query X, i lower_bound X in the set and try to find the closest difficulty according to the conditions in the problem. After this i edit the pairs in the set accordingly.

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

Weak test cases of problem C:

Spoiler

Edit: Test cases are correct

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

    The case is wrong, the given intervals supposed to be disjoint.

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

    Learn to read statement sir :

    Among all problems from all sets, it is guaranteed that no two problems have the same difficulty.

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

    CAN SOMEBODY HELP ME WHAT'S WRONG WITH MY CODE, I AM FIGURING IT OUT FROM 2 HOURS

    KICK START ROUND D 2021

    `

    include<bits/stdc++.h>

    using namespace std;

    define ll long long

    const ll MAX = 1000000000000000000; ll mod = 1000000000; long double pi = 3.141592653589793238; void pls() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    endif

    } /* DON'T STUCK ON SINGLE APPROACH OR QUESTION*/ const ll N = 3e5 + 2; ll n, m; void solve() { int tc = 1; int t; cin >> t; while(t--) { cout << "Case #" << tc++ << ": ";

    cin >> n >> m;
        vector<ll> a;
        vector<ll> b;
        vector<ll> s(m);
        set<pair<ll, pair<ll, ll>>> st;
        for(int i = 0; i < n; i++)
        {
            ll aa, bb;
            cin >> aa >> bb;
            a.push_back(aa);
            b.push_back(bb);
            st.insert({a[i], {0, i}});
            st.insert({b[i], {1, i}});
    
        }
    
        for(int i = 0; i < m; i++)
        {
            cin >> s[i];
        }
         ll cnt = n;
        for(int i = 0; i < m; i++)
        {
            auto it = st.upper_bound({s[i], {-1, 0}});
    
    
    
    
            if(it == st.end())
            {
                it--;
                ll y = it->first;
                ll ix = it->second.second;
                ll dir = it->second.first;
    
                ll sk = s[i] ;
    
                s[i] = y;
    
                ll x = a[ix];
    
                if(x == y)
                {
                    st.erase({y, {1, ix}});
                    st.erase({x, {0, ix}});
                }
                else
                {
                    st.erase({y, {1, ix}});
                    st.insert({y - 1, {1, ix}});
                }
            }
            else if(it == st.begin())
            {
                ll x = it->first;
                ll ix = it->second.second;
                ll dir = it->second.first;
    
                ll sk = s[i] ;
    
                s[i] = x;
    
                ll y = b[ix];
    
                if(x == y)
                {
                    st.erase({y, {1, ix}});
                    st.erase({x, {0, ix}});
                }
                else
                {
                    st.erase({x, {0, ix}});
                    st.insert({x + 1, {0, ix}});
                }
            }
            else
            {
    
                ll x = it->first;
                ll ix = it->second.second;
                ll dir = it->second.first;
    
                // inside
                if(x == s[i])
                {
                    if(dir == 0)
                    {
                        ll y = b[ix];
                        if(x == y)
                        {
                            st.erase({y, {1, ix}});
                            st.erase({x, {0, ix}});
                        }
                        else
                        {
                            st.erase({x, {0, ix}});
                            st.insert({x + 1, {0, ix}});
                        }
                    }
                    else
                    {
                        ll xx = a[ix];
                        if(xx == x)
                        {
                            st.erase({x, {1, ix}});
                            st.erase({xx, {0, ix}});
                        }
                        else
                        {
                            st.erase({x, {1, ix}});
                            st.insert({x - 1, {1, ix}});
                        }
                    }
                }
                else if(dir == 1)
                {
                    ll xx = a[ix];
                    st.erase({x, {1, ix}});
                    st.erase({xx, {0, ix}});
                        a.push_back(xx);
                        b.push_back(s[i] - 1);
                        st.insert({xx, {0, cnt}});
                        st.insert({s[i] - 1, {1, cnt}});
                        cnt++;
                        a.push_back(s[i] + 1);
                        b.push_back(x);
                        st.insert({s[i] + 1, {0, cnt}});
                        st.insert({x, {1, cnt}});
                        cnt++;
    
                }
                else
                {
                    it--;
                    ll lx,lix,ldir;
                    lx=it->first;
                    lix=it->second.second;
                    ldir=it->second.first;
    
                    if(abs(lx - s[i]) <= abs(x - s[i]))
                    {
                        ll sk = s[i] ;
    
                        s[i] = lx;
    
                        ll xy = a[lix];
    
                            st.erase({lx, {1, lix}});
                            st.insert({lx - 1, {1, lix}});
    
                    }
                    else
                    {
                        ll sk = s[i] ;
    
                        s[i] = x;
    
                        ll y = b[ix];
    
    
                            st.erase({x, {0, ix}});
                            st.insert({x + 1, {0, ix}});
    
                    }
                }
    
            }
    
    
        //  for(auto x: st){
        //  cout<<x.first<<" "<<x.second.first<<" "<<x.second.second<<endl;
        // }
        // cout<<endl;
        }
        // for(auto x: st){
        //  cout<<x.first<<" "<<x.second.first<<" "<<x.second.second<<endl;
        // }
        // cout<<endl;
    
         // cout<<a[i]<<" "<<b[i]<<endl;
        // for(int i=0;i<a.size();i++)
        for(int i = 0; i < m; i++)
        {
            cout << s[i] << " ";
        }
        cout << endl;
    
    }

    } int main() { pls(); solve(); return 0; }

    `

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

kostka Seems like someone forgot to change the generic analysis header -- it still says "Thank you for participating in Kick Start 202X Round X!" :)