Codeforces Round 968 (Div. 2) || Editorial for Problem A,B,C,D
ฝัง
- เผยแพร่เมื่อ 18 ก.ย. 2024
- A. Turtle and Good Strings || B. Turtle and Piggy Are Playing a Game 2 || C. Turtle and Good Pairs || D1. Turtle and a MEX Problem (Easy Version)
contest URL: codeforces.com...
Contact me:-
LinkedIn - / swapnil-tayal-53a5b4221
Instagram - / swapnil_tayal
#codeforces #cp #cpp #educational #EducationalCodeforces #div2 #codeforcessolutions #editorial #educational #Codeforces968 #968
❤
Thanks a lot for your help
@@dewsara2888 welcome 😎
great explanation buddyyyy
thanks bro❤❤
C solution:
void solve(){
int n;
cin>>n;
string s;
cin>>s;
map mp;
for(auto &i: s) mp[i]++;
priority_queue pq;
for(auto i: mp){
pq.push({ i.second, i.first });
}
vector a;
int num = pq.top().first;
char ch = pq.top().ss;
pq.pop();
forn(i,0,num){
string s;
s += ch;
a.pb(s);
}
int ind = 0;
while(!pq.empty()){
char ch = pq.top().ss;
int num = pq.top().ff;
while(num > 0){
a[ind] += ch;
num--;
ind = (ind + 1) % (a.size());
}
pq.pop();
}
string ans = "";
for(auto i: a) ans += i;
cout m;
int secMex = 0;
while(x--){
int n;
cin>>n;
set s;
forn(i,0,n) {
int x; cin>>x;
s.insert(x);
}
int num = 0;
int cnt = 0;
while(cnt < 2){
if(s.count(num) == 0){
s.insert(num);
secMex = max(secMex, num);
cnt++;
}
num++;
}
}
if(m < secMex) {
int ans = secMex*(m + 1);
cout
cf id????