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

Автор IceKnight1093, 22 месяца назад, По-английски

We invite you to participate in CodeChef’s Starters 161, this Wednesday, 20th November, rated for all. The contest duration will be 2.5 hours.

Time: 8:00 PM — 10:30 PM IST

Joining us on the problem setting panel are:

Special thanks to satyam343 for discussing several problem ideas with me.


Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.


Problem Distribution:

  • Division 1: 7 problems, one is a subtask

  • Division 2: 7 problems

  • Division 3: 8 problems

  • Division 4: 8 problems

Hope to see you participating.
Good luck!


Congrats to the top 5 in Div. 1!

  1. potato167

  2. noimi

  3. SSerxhs

  4. risujiroh (only participant to solve "Easy Constructive Problem"!)

  5. RNS_JK

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

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

My problem was proposed on 21 Jan 2022.

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

Finally,

Is It RATED ?!
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Hopefully not a Math Chef today:)

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

Reminder: The contest starts in 30 minutes.

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

I struggled with ONETOTHREE during the contest and wondered why so many participants get AC with this problem, but after the contest, I noticed and was amazed that the following scheme is valid.

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

    We can actually prove it by proving that we can never merge islands of 3's. (2's are fixed). I got 1e9+7 WAs before noticing that we have to run the loop backwards as well for smth like 233312 😭

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

    damn I almost thought something like this going forward then backward but didnt try

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

    When I came up with the problem, I had a more complicated casework-y solution, and only later realized that the simple greedy implementation is actually correct.

    I was not sure how guessable this was so I briefly considered modifying the problem to ask for the answer for every prefix or something like that, but after discussing with the tester we decided it's fine to keep it as-is, since for the most part I feel like if you're able to think of this algorithm then it's not too hard to prove it either. (Also it makes for a simple implementation which is always nice.)

    I did make sure to modify the samples so that just iterating forward would pass them though :) (you're welcome RoomTemperatureIQ)

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

What is the time Complexity of this ? I got TLE , is it (4*N)?

int n;
vector<int> a;
int N = 3*1e5+1;
int dp[4][300005];

int rec(int prev, int i){
    if(i >= n - 1) return a[n - 1];
    if(dp[prev][i] != -1) return dp[prev][i];
    int ans = INF;
    if(prev + a[i + 1] == 4){
        ans = min(ans, 4 - a[i] + rec(4 - a[i], i + 1));
    }
    ans = min(ans, a[i] + rec(a[i], i + 1));
    // dbg(ans);
    return dp[prev][i] = ans;
}

void solve() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    memset(dp, -1, sizeof(dp));
    cout << a[0] + rec(a[0], 1) << "\n";
}
  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    You are reinitializing it to dp[4][300005] in each testcase , which prolly gives the TLE, even if you don't get TLE , you will get WA, since this would not consider the cases that the backward iteration considers in the AC solution.

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

It was nice and tricky contest..

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

Good to see that I finally get 7 stars after this contest. My profile

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

Thanks for the contest. QUICKEXIT was such a beautiful problem!

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

The Constraints of QUICKEXIT made me think that I had to do it in O(N2) and my O(N) solution was missing something. ;-;