BledDest's blog

By BledDest, 13 months ago, translation, In English

Neapolis University Pafos

Hello Codeforces!

The series of Educational Rounds continues thanks to the support of the Neapolis University Pafos.

On Apr/28/2025 17:35 (Moscow time) Educational Codeforces Round 178 (Rated for Div. 2) will start.

This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 6 or 7 problems and 2 hours to solve them.

The problems were invented and prepared by Adilbek adedalic Dalabaev, Mikhail awoo Piklyaev, Maksim Neon Mescheryakov, Alex fcspartakm Frolov and me. We would like to express our gratitude to Alexey ashmelev Shmelev for testing the problems and providing us with lots of useful feedback. Also, huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.

Good luck to all the participants!

The round is partially based on the Saratov Multi-University Olympiad and the Nizhny Novgorod Regional Collegiate Olympiad, so if you participated in any of these two competitions, please skip the round.

Our friends at Neapolis University Pafos also have a message for you:

Admission to the Computer Science and Artificial Intelligence Bachelor’s program at Neapolis University Pafos is ongoing!

The JetBrains Foundation is offering 20 fully funded scholarships for talented first-year students.

Each scholarship covers the entire duration of the program, including tuition, accommodation, medical insurance, visa fees, and €300 per month for personal expenses.

Find out more about the CSAI program →

Good news! If you missed the first round, there’s still time to apply for the second round! Submit your documents, pass the entrance test and interview, and receive a full scholarship.

  • Application deadline – June 12, 2025
  • Entrance test – June 15, 2025 (this is the last entrance test for 2025!)

Additionally, there are 2 fully funded scholarships available for students wishing to transfer into the second year of the program (for those already studying Computer Science).

If you have any questions, feel free to ask in the Telegram chat or email us at nup@jetbrains.com !

upd: Unrated registration is possible now. Sorry for the inconvenience.

upd2: The editorial can be accessed here.

  • Vote: I like it
  • +46
  • Vote: I do not like it

| Write comment?
»
13 months ago, hide # |
Rev. 2  
Vote: I like it +30 Vote: I do not like it

hope for a good contest)

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +33 Vote: I do not like it

I wish we could have a

^-^
»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

As a participant, I hope to solve three questions tomorrow.

»
13 months ago, hide # |
 
Vote: I like it +56 Vote: I do not like it

As a participant I hope to see no newbies with Grandmaster skills

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

As a participant, Hope that This contest will be good for all...

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hope to get to orange

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hy everyone, i just started codeforces from the last month. can someone review my profile and tell me wether i am doing ok or not. which parts i neeed to improve. Also, how can questions should i expect from this contest so that i can solve them ?

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Just keep solving the prolems in 800-1200 range atleast for one more month to build a solid foundation. Then move ahead. Your practice regime looks good. Just be at it..

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +12 Vote: I do not like it
    It's a good way to begin with basic algorithms. When my rating was below 1400, I started with partial sums and differences, greedy, binary search and some constructive problems and math problems. The algorithm which left me the greatest impression was double pointers because that was the very beginning of my experiences in Algorithm Contests. It shocked me a lot and made me feel the beauty of algorithms at that time. For me, I have better skill in mathematics than coding, so I always practice harder problems in stuffs like permutations, number theory, etc. Algorithms like DP, searching, data structures (For example: Binary Indexed Trees(BIT), Segment Trees, Disjoint Set Union(DSU)) are also fundamental. I learned them after I became Specialist, but I'm still not really skilled at them yet:C
    Also it's recommended to practice in contests. You can participate in every div4, div3, div2, div1+2 and edu if possible. Atcoder has a type of contests named ABC and begin at 20:00(UTC+8) every Saturday, which are very suitable for beginners. Sometimes you can do Virtual Participation in div3 and div4 rounds before. When your rating gets higher, it could be div2. Sometimes you might encounter a situation that you have the ability to solve some problems, but don't have enough time to pass in the contest. This time don't forget to make more trials after the contest, it will help a lot if you get Accepted.
    Different people might have various learning process from each other. Hope you will enjoy your time in Codeforces and become more skillful in the future!
»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I'm not getting the normal "out of competition" reason when registering for this contest. Is this a bug?

»
13 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Positive delta pls

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Those who participated in any of those rounds and decided to participate in this round too – then how can Codeforces stop them?

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it -9 Vote: I do not like it

    It's roughly the same thing as testers not participating in a contest that they tested from their main account, through their alt account: mainly trust-based.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why unrated participation is not there this time?

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

It is my first game in codeforces.I hope that I will pass at least 1 question.I don't know how hard the questions because I am a beginner of computer science.Good luck for me.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    don't worry,you'll soon find out,no matter how hard is it,just to remember keep calm and carry on!

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    div.2 is hard for beginners, try div.3 or div.4 contests. by the way i believe you can solve at least 1 question. but don't push yourself to solve all questions. keep calm and concentrate on first two problems. if you could solve them that is really great and would give you a nice start rating.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      I solved 2 questions at last,and ranked 8626.I think it's a good result for a beginner.btw,I don't know how to participate in div3or4,I can only find div1 or2 in the contests page

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        That' beacause at the time only div1 and div2 contests are available. In the future, div3 and div4 contests will also appear in your contest page.

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it +3 Vote: I do not like it

        thats really nice if you could solve 2nd actually.

        i dont see any upcoming div.3/div.4 contests too. they will be added later, you should keep checking contests page ( i do everyday ).

»
13 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

It looks like the opportunity for unrated registration for the round was accidentally turned off. We have turned it back on; you can now use unrated registration. Sorry for the inconvenience.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What's the difference in normal round and edu round?

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Here I am, an old CP guy, trying his luck again. Need all of your luck!

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

actually I noticed for first time that there is unrated registration option... is this available for div2 and other contests as well ?

I think this is a really useful feature and didn't know about it

»
13 months ago, hide # |
 
Vote: I like it -28 Vote: I do not like it

Love this contest for:

  1. The clear declaration;

  2. Balanced problem difficulty distribution so that we perform better than we did in some unbalanced div2 based on the number of solved questions.

»
13 months ago, hide # |
 
Vote: I like it +34 Vote: I do not like it

Speedforces strikes again

»
13 months ago, hide # |
 
Vote: I like it +38 Vote: I do not like it

there are so many cheaters in this contest , idk if this could be handled or not but we should take a look at D E F G solvers

»
13 months ago, hide # |
 
Vote: I like it +42 Vote: I do not like it

Div.3 Round :)

»
13 months ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

loved the round...truly an educational round(atleast for a newbie like me) learnt a lot from the problems:))

»
13 months ago, hide # |
 
Vote: I like it +56 Vote: I do not like it

Is it a Div.3 ????

»
13 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

This is my first contest in codeforces, I'd say I've enjoyed it though i only solved 3 of them :) The problem C was interesting for me.

»
13 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

wtf is test 6 on E

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    my solution for each t is: find the optimal subsequence within s(optimal meaning that the last letter used is at the lowest index possible), then for the remainder of the string s, just figure out the smallest string which isnt a subsequence of that remainder of the string. i think the idea is correct, and that i messed up in implementation, but its weird that so many people also had wa on test 6, so i dont know

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    For me, it was related to the transition between DP states. You can compare my last 2 submissions.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve E ?_?

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +5 Vote: I do not like it

    You can use a array of set to store the position of every char to check if a string lie as a subsequence or not in NlogN then two cases are possible:

    • the string t is not found as a subsequence in s straight away the answer is 0
    • if the string t is exhausted you will have the last position in s upto which the prefix substring is capable of giving t now we can try out all possible k characters one by and the raising the required pointer to that index, basically trying out all possible cases , we can optimise this with dp

    My submission link : submission link

    although I am not sure it will pass hacks or not cause the time consumption is really on edges

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      it's not necessary to use a set. you can pre-process an array pos[N][26], pos[i][j] means the next position of a letter(j) starting from the current position i. so the time of binary search will be spared

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        I had exactly done this but after looking other solution i do realize it does not make much diff if we use binary search or this approach as it will take 26*n time to precompute in this approach and it will take 10^5 * logn time for queries if done with other approach and for constraints of problems both are approx. same

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The problem statements were both concise and brilliant. TFM!

»
13 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

https://www.youtube.com/live/tf5RnMbFyRk?si=eFgYAEuREH-SP9cq

Youtube channel: @learningunique codeforces handle: aayushrathour34 doing livestream during contest

»
13 months ago, hide # |
Rev. 3  
Vote: I like it +6 Vote: I do not like it

jump in diff from e to fg was lowkey crazy xd well written ps though

»
13 months ago, hide # |
Rev. 7  
Vote: I like it +76 Vote: I do not like it

codeforces $$$\times$$$

cheater forces, gap forces $$$\sqrt{}$$$

I can confirm there are infinity cheaters solve DEFG fast

upd: Cheaters can get solution during the contest on https://www.youtube.com/results?search_query=Educational+Codeforces+Round+178+(Rated+for+Div.+2), it is ez to find it

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Could someone help me with problem D? I have made an observation that the array is "ideal" if and only if all of the elements of the array are primes, and then I tried to run a binary search to find how many elements have got to be deleted, but it gave WA 2?

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    you should binary search over amount of elements being deleted ( say k ) at each step of binary search, you check if deleting k smallest elements helps.

    to check, you should use the fact that any array with sum S and N elements. can converted to N first primes iff S >= sum of N first primes

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Can you show why it is not possible if sum of the array < sum of N primes?

      I got stuck at the thought of making the first N-1 elements as primes and whatever is left from the sum can "Maybe" be used to make the entire array satisfy the gcd condition. but i couldn't find a proof :(

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        If the sum is not atleast the sum of primes, then all the elements can't be distinct primes , so some of the numbers have to share factor with some other , which violates the condition(two elements should have gcd =1) , so decrease the array size till you can satisfy sum of array >=sum of array.size() primes.

        • »
          »
          »
          »
          »
          13 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          yeah i figured that duplicate primes exist and then it violates the gcd condition, but is there a way to put composites that dosent violate the gcd condition?

          • »
            »
            »
            »
            »
            »
            13 months ago, hide # ^ |
             
            Vote: I like it 0 Vote: I do not like it

            composites are 1 or more primes themselves used , so if you use composites ,it becomes worse as now you cant use the 1/+ primes used in one number in another number , meaning if a[i]=p*q say , then what we could have used p and q for 2 different numbers .

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +2 Vote: I do not like it

    Try to convert the largest element of array into smallest prime number, it will give you additional coins for future.

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    so make an increasingly sorted array of the first n primes,and sort a decreasingly, then just find the first element where the prefix sum of the primes is larger than the prefix sum of a, those are all the elements that can stay, so the answer is n-(index of that element). no need for binary search

»
13 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Beautiful problems. thank you!

»
13 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

What in the Speedforces' sake is this? I misread problem E from "adding to the right" as "adding from the right" and lost 1000 rankings.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Very nice problems, especially problems D & E. Thanks for preparing such contest! ^^

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +4 Vote: I do not like it

E: only if I can solve https://mirror.codeforces.com/contest/1925/problem/C in O(26 * log n) :sob:

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    It made me remember the exact same problem :)

    I find it very interesting how the brain works for people to remember a problem from over a year ago.

»
13 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

One of my best contest yet, I was able to solve 5 questions in Div2 for the first time :)

»
13 months ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

kid named problem F

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For problem E, I tried to implement a greedy approach using Binary search on the indices. Got TLE on Testcase 9 :(

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +2 Vote: I do not like it

    you can optimize your approach by precomputing the result using DP

    for each index $$$i$$$, what is the minimum number of allowed letters that I can add such that it won't be a beautiful string?

    precompute this using DP and your answer should work well

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    Greedy works. you used binary search to find the string 't' last index right? now you can again use binary search to calculate number of operation required.

    come from last on string s, put all index to some list when all k character are visited. now binary search on that list.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    Same thing happened with me . I was able to figure out my error just after the contest :(

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

317640862 can someone explain me why 1e6 primes are not enough in problem D? (given n<=4.1e5)

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    You checked the first 1e7 numbers so that doesnt contain 4e5 prime numbers needed to calculate the prefix sum

    • »
      »
      »
      13 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it +2 Vote: I do not like it

      Actually 1e7 numbers contains ~6e5 primes which is sufficient but I did a mistake in finding primes. :(

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +4 Vote: I do not like it

    because you need about 6e6 numbers to get 4e5 primes

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +4 Vote: I do not like it

    Your code doesn't generate 1e6 Primes, it only generates all primes less than 1e6. Your code roughly generates ~78000 primes.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    okay the i went like this,as the size of array is 4*(10^5) that means we need atmost this number of primes and i used cpp to find that number in vs code.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Yes, but the size you need to allocate has to be upto the 4e5 the prime number which happens to be around 6e6 so allocating 1e6 is not enough.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    for (int j = i*i; j <= N; j += i) is_prime[j] = false; //================ int N=1000000; //1e6

    Doesn't that mean that in some cases you do not mark enough values as being composite?

»
13 months ago, hide # |
 
Vote: I like it +17 Vote: I do not like it

div2 or div3???

»
13 months ago, hide # |
 
Vote: I like it +29 Vote: I do not like it

Was the contest way easier than usual?

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

can someone please help, why doesn't my submission 317647877 work for C?

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    When s[0]=='B' and s[n-1]=='A',that is #1 in Bob,#n in Alice.

    As long as #n-1 in Alice, Alice will win since only #n can beat #n-1 but Alice owns it.

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Missed E by 2 min. shit. It was easier than D.

»
13 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

When will submissions open?

»
13 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

I hope that system tests are strong enough

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

just look at number 6,7,8,9,10,11,12 in the div2 standing why they don't get banned????

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

expected ratings of b and c?

»
13 months ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

Speedforces type shit

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +30 Vote: I do not like it

A to E are easy for being a Div.2 problems and the whole contest (A-G) was leaked in YT. I wish CF find a solution for this unfair competition. However, the contest is below the average as a div2. I know some contestants will not like my opinion but see that your delta doesn't rate the contest (like getting +100 the contest is cool while getting -50 the contest is bad).

»
13 months ago, hide # |
Rev. 2  
Vote: I like it -21 Vote: I do not like it

Please, Check my solution for D and tell what's wrong

vector<bool> seive(ll n){vector<bool>primes((n+1)/2,0);for(ll i=3;i<n;i+=2){if(primes[i/2]==false)for(ll j=i*i;j<n;j+=i*2){primes[j/2]=1;}}return primes;}
vector<bool>primes;
vll p;
void solve(){
    int n;
    cin>>n;
    vll arr(n);
    for0(i,n)
    cin>>arr[i];
    sort(arr.begin(),arr.end());
    vll left;
    int m = p.size();
    int j=0;
    ll coin=0;
    int i=0;
    for(;i<n;i++){ 
        coin += arr[i]-p[i];
    }
    for(i=n-1;i>=0&&coin<0;i--){
        coin-=(arr[i]-p[i]);
        coin+=arr[i]-2;
    }
    
    cout<<n-i-1<<endl;
}
int main(){
    fast_io();
    primes=  seive(1e6*7);
    p.pb(2);
    for(ll i=3;i<=1e6*7;i+=2){
        if(primes[i/2]==false)
        p.pb(i);
    }
    int T;
    cin>>T;
    
    while(T--)
    solve();
}
  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it -8 Vote: I do not like it

    Hey Amigo I don't understand how you find prime numbers. :/ I use sieve of Eratosthenes; https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

    And that after deleting the numbers, only their sum is important. Its my code :

    #include <bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #pragma GCC optimize ("O3")
    #pragma GCC optimize ("Ofast")
    using namespace std;
    const int N = 1e5 + 100;
    
    signed main(){
    	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    	int t;
    	cin >> t;
    	while(t--){
    
    		int cntb = 0, cnta = 0;
    		int n;
    		string s;
    		cin >> n;
    		cin >> s;
    		for(int i = 0; i < n; i++){
    			cntb += (s[i] == 'B');
    			cnta += (s[i] == 'A');
    		}
    		s = '.' + s;
    		if(s[n] == 'B'){
    			if(cntb > 1)
    				cout << "Bob" << endl;
    			else
    				cout << "Alice" << endl;
    		}
    		else if(s[1] == 'A' or s[n - 1] == 'A')
    			cout << "Alice" << endl;
    		else
    			cout << "Bob" << endl;
    		
    	}
    	return 0;
    }
    
    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it
      #include <bits/stdc++.h>
      #define ll long long
      #define pb push_back
      #define all(x) x.begin(), x.end()
      #pragma GCC optimize ("O3")
      #pragma GCC optimize ("Ofast")
      using namespace std;
      const int N = 1e7;
      
      bool cmp(int &a1, int &a2){
      	return a1 > a2;
      }
      bool mark[N];
      vector<ll> vec;
      
      signed main(){
      	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
      
      	for(int i = 2; i < N; i++){
      		if(mark[i] == 0){
      			if(vec.empty())
      				vec.pb(i);
      			else
      				vec.pb(i + vec.back());
      
      			for(int j = i; j < N; j += i)
      				mark[j] = 1;
      		}
      	}
      	int t;
      	cin >> t;
      	while(t--){
      		int n; 
      		cin >> n;
      		int a[n];
      		for(int i = 0; i < n; i++)
      			cin >> a[i];
      		
      		sort(a, a + n, cmp);
      		int k = n;
      		ll sum = 0;
      		for(int i = 0; i < n; i++){
      			sum += a[i];
      			if(sum >= vec[i])
      				k = n - i - 1;
      		}
      		cout << k << endl;
      		
      	}
      	return 0;
      }
      

      Sorry, I sent the wrong code :>

      • »
        »
        »
        »
        13 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it +3 Vote: I do not like it

        My seive logic is correct I checked, but the problem was in my logic

        I increased my coins by decreasing the unwanted elements to 2 as in question it mentioned they should be atleast to 2 then I deleted them

        That's why I got extra score, it is not clearly mentioned in problem we can't do that I used a lil extra brain it's so funny

        My submission got accepted now thanks man

»
13 months ago, hide # |
 
Vote: I like it +19 Vote: I do not like it

I like that div3

»
13 months ago, hide # |
 
Vote: I like it +46 Vote: I do not like it
»
13 months ago, hide # |
 
Vote: I like it +26 Vote: I do not like it

This is the simplest div2E I have ever seen, the last one so simple was 1978E, and it is recommended that the producers consider the difficulty gradient of the problems.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +32 Vote: I do not like it

The system testing is stuck at 100% because a certain submission is stuck at running on test 1. You can filter submissions to check that.

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

speedforces

»
13 months ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

Today's contest was so easy a bunch of greys AK'd the contest.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

what is the idea for E?

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    from a particular position to append a new character it's always optimal to go to one particular index which creates a DAG structure so you can call it dp too

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    The high level idea is this:

    For a single query T, let U be a prefix of S that contains T as a subsequence, and V be the corresponding suffix (i.e., S = UV). If there is no such U then T is not a subsequence of S at all and the answer is 0. Otherwise, the number of characters we need to add to T to make it not a subsequence of S is equal to the number of characters in the shortest string that is not a subsequence of V. Note that this number depends only on the length of the suffix, not on the specific contents of T.

    Let's call this number $$$extra(i)$$$, defined as “the number of characters in the shortest string that is not a subsequence of the suffix of S starting at 0-based index $$$i$$$”. Clearly the values of $$$extra(i)$$$ are nonincreasing as $$$i$$$ increases, since any string that is a subsequence of some suffix of S is also a subsequence of a longer suffix of S (note: lower $$$i$$$ means longer suffix).

    This implies that for any particular T, we only need to find the shortest suffix U.

    Define $$$next(i, c)$$$ as the least index $$$j ≥ i$$$ such that $$$S[j] = c$$$. We can precalculate this in $$$O(26×N)$$$ time.

    We can also calculate $$$extra(i)$$$ in $$$O(26×N)$$$ time using $$$next(i, c)$$$ (this is dynamic programming, technically).

    Now for a given T, we use $$$next(i, c)$$$ to find the shortest prefix U that contains T as a subsequence in $$$O(|T|)$$$ time by repeatedly finding the next character of T in S. When we've found U, we simply return $$$extra(|U|)$$$ as the answer.

    This solution takes $$$O(26×N)$$$ preprocessing time, and additionally time proportional to the sum of the lengths of the query strings T, which is bounded to $$$10^6$$$.

    This is the logic behind my submission 317615565.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to do task C about card game, can somebody explain it please ?)

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    Suppose Alice has a card that Bob doesn't have a counter. Then, Alice can keep playing that card until Bob gives all his cards. Hence, Alice will always be able to win. Only in the case when Alice do not have any card that Bob doesn't have a counter, Alice looses.

    To find counter of a card, for card 1 to N — 1, you can check if any card with greater label exist on opponent's hand and for card N you can check if card 1 exists on opponent's hand.

    This is the simplest way to solve the problem. It can further be optimized by making other observations but given the problem constraints this was sufficient.

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    I had this idea:

    Every card beats card that is less with exceptions: 1 beats n

    So i made graph where for each card i store list of cards which beats it. After this for EVERY card that Alice have i'm checking if Bob have ANY card that beats it using graph earlier.

    You can check my submission: https://mirror.codeforces.com/contest/2104/submission/317613034

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +3 Vote: I do not like it

    I just enumerated the different cases:

    1. If Alice has 1 and N, then she can win by always playing N which beats every card Bob has.

    2. If Alice has 1 but not N, then there are two cases:

      1. if Bob only has N, then Alice wins by playing 1.
      2. otherwise, Alice loses, because Bob can play N every time except when Alice plays 1.
    3. If Alice has N but not 1, then:
      1. if Alice also has N-1 she will win by only playing N-1, which beats every card Bob has.
      2. otherwise, she will lose, because when Alice plays N Bob will play 1, and when Alice plays any other card, Bob will play N-1.
    4. Otherwise (Alice has neither 1 nor N), she loses because Bob can always play N which beats every single card Alice has. (This is the converse of case 1.)

    So Alice only wins in cases 1, 2a and 3a, which are easy to detect.

»
13 months ago, hide # |
 
Vote: I like it +95 Vote: I do not like it

s

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

i dont understand why is my brute force solution getting wrong answer 317666531 can anyone help me out ? i also checked out other's solution it is the same if u test it mathematically

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +19 Vote: I do not like it

    You're making the mistake that one of the announcements explicitly addressed:

    “You are not allowed to increase/decrease elements and remove them afterwards. You have to remove the minimum number of elements to make the array beautiful, without applying the operations that change elements. They only define which array is beautiful and which is not.”

    So for a test case like:

    1
    6
    5 5 5 5 5 5
    

    Your solution will print 1 while the correct answer is 2. That's because you figure that $$$2 + 3 + 5 + 7 + 11 = 28 ≤ 6×5 - 2 = 28$$$ but in reality if you remove 1 element you only have $$$5×5 = 25$$$, so you must remove a second element and then $$$2 + 3 + 5 + 7 = 17 \lt 4×5 = 20$$$.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

could any one please tell why this solution deosnt work for problem D Educational Codeforces Round 178??

My approach was to reduce every element of the array to '2' thus increase coins by a[i]-2.. so for each i from 1 to n I will do coins+=a[i]-2.

This is the maximum coins I can have..Now since the elements of the array are all'2' I will start assigning each element to a smallest available prime number starting from '2' for a[1]... Then I will check if I have enough coins left to transform a[2](which is '2' currently) to 3(next smallest prime number). If I have, then I reduce my coins by the curr available prime number-a[i]...

SO for each i I check if coins left >=required coins to transform the ith element to the next available prime number. If the ith element can not be made prime then we stop . And the number of elements which could not become prime number is the answer...

Please tell where I am wrong because I think my approach is right but its failing the second test case.....

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

can somebody hack my solution solution for problem e.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +9 Vote: I do not like it

    Oops, sorry. I have succeeded. Didn't expect it myself

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      Thanks brother

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Can you tell how hacking works, the articles on hacking are rather ambiguous.

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it +3 Vote: I do not like it

        Hacking is, basically, coming up with some test which would give WA/TLE (basically any incorrect verdict) on someone's solution.

        There's two methods for uploading a test, which are: 1) upload the txt 2) upload the code which yields the output for testcase.

        The second option's program called generator. Here's the code which I submitted as generator.

        Generator's code

        To get some idea, what exactly is generated you can run this code locally and set N = 1e2, Q = 1e1.

        Your output also has to be correct regarding problem's constraints, i.e. n <= 1e6, Q <= 2e5 etc.. If not, then the problem checker would say something like "incorrect testcase"

        That's all I think you have to know to start hacking yourself. Good luck

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      how about now is it still possible to hack

»
13 months ago, hide # |
Rev. 2  
Vote: I like it -13 Vote: I do not like it

came back to cf after a long time felt good solving E

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Who can tell me why my rank on the common standings is different from the friends standing?They're 65 and 99,and I'm sure the rating is base on the second one.Because in the last Div.2,they are 706 and 845 ,and the rank on the rating board is 845.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Do I get something wrong about D ? For the test cases $$$[2, 4]$$$ the answer shall be that we have to remove $$$1$$$ element (i.e. $$$4$$$ here) , But the AC code of the guy having rank $$$1$$$ gives $$$0$$$ as the output.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve the problem F please? I guess there was too much different conditions that I didn't discuss about them completely.

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Is the system testing done? Or yet to begin?

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +6 Vote: I do not like it

Forgot that the constraint for problem F was $$$n \le 10^9$$$ and solved it as if $$$n \le 10^{10^6}$$$. Maybe it’s a good idea to split it into an easy and a hard version :)

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    Could you explain your idea?

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it +5 Vote: I do not like it

      Consider which $$$x$$$ there does not exist any $$$y \lt x$$$ such that $$$S(x) = S(y)$$$. Excluding the obvious cases (for example, $$$y = 12349$$$ comes before $$$x = 32149$$$), $$$x$$$ is also not allowed to end with two or more $$$9$$$ (for example, for $$$x = 12399$$$, you can construct $$$y = 10293$$$), except for special cases such as $$$x = 1999\ldots9$$$, $$$x = 2999\ldots9$$$, ..., $$$x = 9999\ldots9$$$, and therefore, you also need to specifically consider numbers like $$$x = 90091$$$, because even though they meet the conditions above, $$$y = 19999$$$ paradoxically comes before it.

»
13 months ago, hide # |
Rev. 4  
Vote: I like it +3 Vote: I do not like it

for problem G, i tried to implement the idea of square root decomposition on queries, and build a compressed graph for every block of queries, time complexity is $$$O(N\sqrt N)$$$ its giving tle at testcase 8.

Submission: 317677095

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Check Pratap1617, he is kinda high for a pupil and his comments are kinda odd, if you know what i mean

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone give some hints for problem F?

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    The number of distinct f(x)'s for x <= 10^9 — 2 is small enough to precompute them.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I came to an example which feels close to solution: s(762)=s(672), so intuitively counting distinct strings means counting numbers where each less significant digit is >= more significant, except for least significant, which usually can be any. And need to figure out what to do with zeroes and tailing 9's s(3799)=s(3077), or s(3099)=s(3090).

»
13 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Hi can someone help me figure out why my solution for E TLE for system tests and how I can improve it? If Im not wrong, it's already linear complexity with respect to (n + t).

317634919

Thank you in advance!

  • »
    »
    13 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it +5 Vote: I do not like it

    You check the entire string s for every query In the worst case if the queries aren't subsequences then the entire original string will be traversed q times with makes it around 5e11 somthing.

    I failed on sys test too.

    And to improve it I guess we could traverse the original string using the next character array we've build rather than traversing every element

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I also got TLE in test case 29 in problem E. I think you have to reduce the constant factor, because the constraints were tight.

    • »
      »
      »
      13 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      Although, I checked the string only once and stored its data in a map. I think I should have used unordered map

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        You can iterate over t_i every query, because the sum of lengths of t_i is bounded, but not over s, your solution is at least O(q * n), which is too slow

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        (you did not in fact checked the string only once)

        while(i1<n && i2<l){
        
            if(t1[i2]==s[i1]) {
        
                i1++;i2++;
        
            }
        
            else i1++;
        
        }
        
»
13 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

When are the ratings gonna update [ : ( ] ??

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

This is a humble suggestion. Correct me if I'm wrong.

It is better to refrain from mentioning "This round is based some some X Olympiad". Let's say there were some Y people who participated in X, instead of informing them this disclaimer is helping at least 10Y people cheat. BledDest

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    It doesn't make sense, if they participated in X they will recognise the problems even without the mention, and with the mention good people just skip the contest.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      But so many cheaters are getting benefitted. Answers are getting leaked on YT so soon. Beginners who genuinely perform good finish way lower than the rank they deserve and get demotivated.

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        Not warning people that it's almost the same contest that they had before doesn't solve the cheating problem.

        • »
          »
          »
          »
          »
          13 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          How on earth! You beforehand let the cheaters know the questions are gonna be from here and one of them who finds the answers leaks it on YT or Telegram. At least this can be avoided

          • »
            »
            »
            »
            »
            »
            13 months ago, hide # ^ |
             
            Vote: I like it 0 Vote: I do not like it

            This is an onsite regional contest, not some freely available online contest. People leak solutions either way

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I couldn't get what the fourth question was asking for , how did some people solves it in 19 mins !! , damn too good to look true and that too with 100+ lines of codes with names of variables as anime characters , damn !!

»
13 months ago, hide # |
 
Vote: I like it +38 Vote: I do not like it

»
13 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

When is the editorial coming out??

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

solve problem F ạ

»
13 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

what is the intuition behinf E?

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    you should find first occurrence of string t in s as subsequence. if there is no occurrence, then answer is zero if there is subsequence ending at index i. you should find the minimum length string that is not subsequence of s[i+1..n]. which is possible to find using dfs & memoization ( dp )

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Since when did you have to solve 4 "FOUR". Since when did you have to solve 4 DIV 2 Problems. YOU HEARD ME RIGHT, 4 DIV 2 problems to become GREEN.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

when will the editorial come out?i can't wait to know how to solve the F properly.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

[Your text to link here...](https://blog.csdn.net/qaqwqaqwq/article/details/123587336) Dear administrator, I sincerely hope you can revoke the cheating penalty imposed on me. Problem 2104D significantly coincides with solutions hangogogo/317624815 and KrAuAg/317633096. I suspect this is because we might have used the same website template. I found the Euler sieve template in the CSDN community, specifically from the website https://blog.csdn.net/qaqwqaqwq/article/details/123587336. I don't know the user KrAuAg. I think the similarity between his code and mine is probably due to the fact that we found the same template on the same website. I'm truly sorry for the trouble this has caused. I deeply apologize for any inconvenience or misunderstanding this situation might have brought to you and the platform. I really respect the rules and regulations here and always strive to abide by them. Thank you very much for your time and understanding. Looking forward to your kind consideration. Best regards, for hangogogogo