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.