A B C解释| Google Code Jam 2020 Qual Round的截屏视频



如何快速解决Google Code Jam 2020资格赛的A B&C?这是我的屏幕录像,其中包含注释后和解决方案说明。期待更多视频,因为我正在争取再次进入决赛。有关比赛的更多信息https://codingcompetitions.withgoogle.com/codejam和圆形链接https://codingcompetitions.withgoogle.com/codejam/r​​ound/000000000019fd27

订阅更多有关算法,编码访谈和竞争性编程的教育视频。

-Github资料库:https://github.com/Errichto/youtube
-在第二个YouTube频道和Twitch上进行直播:https://www.youtube.com/errichto2&https://www.twitch.tv/errichto
-FB和Twitter:https://www.facebook.com/errichto和https://twitter.com/errichto
-常见问题解答:https://github.com/Errichto/youtube/wiki/FAQ

#Coding#编程。

22 comments
  1. I did B slightly differently, I appended zero to either end of the list, then iterated through the list.

    if digit_current-digit_next < 0:
    for _ in range(abs(digit_current-digit_next)):
    temp=temp+"("
    And the opposite for if >0 otherwise, just skip straight to adding the values.
    (Sorry if that doesn't make sense, also, sorry about the tabbing)

  2. I don't yet know how you solved problem B (the 00(1(2)) problem), but I think if you just go through the numbers from left to right, the number in each place stand for how many open parenthesis there are.

    So we start with current_open_parenthesis = 0, and the first number is 2, we can replace this "2" by "((2" and have current_open_parenthesis += 2.

    If the next number is a 1, we replace it by ")1" since then only 1 parenthesis is opened, and do current_open_parenthesis -= 1.

    In the end, we add current_open_parenthesis times ")".
    edit: nvm, this is exactly how you did it.

  3. For Vestigium you can easily improve time complexity to O(n^2) without using data structures. Notice that there where only numbers from 1 to n and so you can just create an array that counts number of appearances of each number.

  4. I have this small question errichto or anyone in chat may be able to answer!
    So does he input the test case in to one of his programs and then the program cooks up a cop file with all input and output handled and then he just has to write the main program in the function defination.
    OR
    As the input data is fairly in same form in every question he just has a program written. IF yes then y does he input the test case into a program ever time before the question begins??
    Hello errichto it is amazing to watch u solve it so fast.

    I only could get 24 points !!

  5. Great Video! In problem C, is it possible to simply assign tasks to each one without any sortings? Just checking if they are available in that range. I strongly believe that it is a valid solution

  6. I also wanted to sort the intervals by starting time in problem 3 but later instead of that I iterated from 0 to 1440 twice to assign earliest task to J and if he is not available then to C. It worked out since the maximum time interval is constant = 1440.

  7. i am a beginner and done this for 1st problem :

    #include<iostream>

    #include<vector>

    #include<set>

    #include<unordered_map>

    #include<algorithm>

    #define f(i,a,n) for (int i = a;i<n;i++)

    #define fo(i,n) f(i,0,n)

    using namespace std;

    typedef unordered_map<int,int> mi;

    typedef vector<int> vi;

    typedef vector<long> vl;

    typedef long long ll;

    struct hash_pair{

    template <class T1,class T2>

    size_t operator()(const pair<T1,T2>& p) const

    {

    auto hash1 = hash<T1>{}(p.first);

    auto hash2 = hash<T2>{}(p.second);

    return hash1 ^ hash2;

    }

    };

    int main(){

    int t,k=0;

    cin>>t;

    while (t–){

    int n;

    cin>>n;

    unordered_map<pair<int,int>,int,hash_pair> c,r;

    mi jdone;

    int trace = 0,rc = 0,rr = 0,ot;

    fo(i,n){

    ot = 0;

    fo(j,n){

    int x;

    cin>>x;

    if (i == j) trace += x;

    r[{x,i}]++;

    c[{x,j}]++;

    if (c[{x,j}]>1 && jdone[j] != 1) {

    rc += 1;

    jdone[j] = 1;

    }

    if (r[{x,i}]>1 && ot == 0) {

    rr +=1;

    ot = 1;

    }

    }

    }

    k++;

    cout<<"case #"<<k<<": "<<trace<<" "<<rr<<" "<<rc<<"n";

    }

    return 0;

    }

    is it a nice solution or just stupid ??

  8. Hey Errichto, thank you for the editorial, can you please explain why I cannot sort the "size of interval" in problem 3?
    I implemented the solution for 3 very fast, but got stuck for WA even with the small test case set 1 for long time.
    After I change my sorting criteria from width of the interval to starting time of the interval, it surprisingly passed.

Comments are closed.