CodeChef Break-The-Server

yeah it was, prefix sums+ lca

1 Like

why push this notification multiple times , ek baar bola to no thanks …so annoying.

@admin

2 Likes

I did the same and got TLE.
can you look into this code once and tell the reason for TLE.

I think 1-4 were very easy and (just an opinion) suddenly 5 was hard. It was lowest common ancestor, which is hard to implement…

I think using endl instead of “\n” is screwing up the things. They specifically mentioned to use fast IO

1 Like

Oh , ok thanks , actually in contest I was in a hurry at the end , so just wrote endl which I usually write . Thanks mann.

1 Like

Adding #define endl "\n" in your template might help in case you’re habitual of writing endl

3 Likes

Ok :slight_smile:

Anyone please what is wrong in my 4th question
here is solution

The strange thing is 10^10 should be around 100 sec execution time and the memory will also be around 10GB for an array of size 10^10. In the verdict the, time taken was 0.00sec and memory was 14.9MB.

Because -O2 optimization flags removes the redundant parts of your code.
Here is my test results

2 Likes

Thanks to everyone who participated in the contest!

The issue in the first few minutes was a very regrettable manual error from our end wrt moving the problems, and had nothing to do with the servers. Apologies for that delay.

We’ll keep you updated about our future contests. Thanks once again for helping us with testing :slight_smile:

3 Likes

Please make the submissions of others public
It’s not visible now

Yes they are still not visible, for the time being you can go to the practice section to find solutions

Any hint on how to solve https://www.codechef.com/CCHI2021/problems/CCBTS04 ? Please share the code and explanarion also

This can be simply solved by modifying the well known longest increasing subsequence problem a bit. Just adding another if condition does the job. I think the code is self - explanatory.
Code:

#include<bits/stdc++.h>
using namespace std;
int lis(vector<long long int> &arr, vector<long long int> &a, int n){  
 long long int lis[n]; 
 lis[0] = 1; 
 for (int i = 1; i < n; i++ )  
 { 
     lis[i] = 1; 
     for (int j = 0; j < i; j++ )   
         if(arr[i] > arr[j] && lis[i] < lis[j] + 1 && a[i] < a[j]){  
             lis[i] = lis[j] + 1;
         }
 } 
 return *max_element(lis, lis+n); 
}  
void solve(){
 int n;
 cin >> n;
 vector<long long int> arr(n), a(n);
 for(int i = 0; i < n; i++){
     cin >> arr[i];
 }
 for(int i = 0; i < n; i++){
     cin >> a[i];
 }
 cout << lis(arr, a, n) << "\n";
 return;
}
int main(){
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t;
 cin >> t;
 while(t--){
     solve();
 }
}
1 Like

I did the same and got TLE.
Can you look into this code and tell me where to optimize it.
I used prefix sum + LCA using the sparse table.
Thanks :wink:

There seem to something wrong in test data of first problem. Maybe there’s a extra space in the string. That’s why these kind of submissions in python (1, 2, 3) are giving WA.

1 Like

Yes is it compiler optimization. You may wanna try 10e18 loop or nested loops :wink:

1 Like

just checking