Comments

It is because the elements which are only of type2 would always exist as single continguous strip in an interval (l,r) ,for those i%k would be cyclic anyways.

  • Can someone pls explain what is wrong in my solution for D. Getting WA
  • My Approach: The straight forward thing is the minimum number of sub-sequences we need to break, that number is directly the maximum of count of consecutives 1s or 0s. Because each one of consecutive 1s or consecutive 0s should definitely be on different sub sequences.
  • Second thing is to parse into sub-sequences, For example if the string is 001110110000011, my way of breaking into subsequence would like ith element in a series of k consecutive same char would go into ith list.
  • Basis on that my listing would be something like
  • 0 0
  • 1 1 1
  • 0
  • 1 1
  • 0 0 0 0 0
  • 1 1
  • Each column here would be considered as subsequence so there should be 5 subsequence.
#include <bits/stdc++.h>
using namespace std;

vector<int> minSubSequencesCntList;
vector<vector<int>> subSequenceLists;

void breakIntoMinSubsequences(string s){
    int n = s.length();

    vector<int> subsequenceList;
    int minSubsequencesCnt = 1;
    
    char curr_c = '2';
    int currCnt = 0;
    for(char c: s){
        if(curr_c == c){
            currCnt++;
        } else{
            currCnt = 1;
            curr_c = c;
        }
        subsequenceList.push_back(currCnt);
        minSubsequencesCnt = max(minSubsequencesCnt,currCnt);
    }

    minSubSequencesCntList.push_back(minSubsequencesCnt);
    subSequenceLists.push_back(subsequenceList);

    return;
}

int main(){
    int T;
    cin>>T;

    while(T--){
        int n; 
        cin>>n;

        string s;
        cin>>s;

        breakIntoMinSubsequences(s);
    }

    int totalTestCases = minSubSequencesCntList.size();
    for(int testCase=0;testCase<totalTestCases;testCase++){
        cout<<minSubSequencesCntList[testCase]<<endl;
        for(int ele: subSequenceLists[testCase]){
            cout<<ele<<" ";
        }
        cout<<endl;
    }
}
On Diall_Codeforces Round 1013 (Div. 3), 13 months ago
0

Thankyou, I didn't know that it takes 4-5 hrs to reflect after hacking round.

On Diall_Codeforces Round 1013 (Div. 3), 13 months ago
0

I see the contest in my timeline as unrated contest. Can't understand why

On Diall_Codeforces Round 1013 (Div. 3), 13 months ago
0

Why hasn't my rating got reflected, although I understand that i am not a trusted participant because I have participated in less than 5 contests, but it says if my rating was never above 1600 it would be considered as rated right, can someone explain.

Dude can you please share me the tips what did you do for CCAT,actually I have the test tomorrow.