Hey everyone! I’m relatively new to competitive programming and have been diving into platforms like Codeforces lately. It’s been an exciting but humbling experience, and I’m constantly learning. If you have any advice for improving problem-solving skills or tackling contests efficiently, I’d love to hear it!↵
↵
Now, let me share a recent puzzling experience I had while solving a problem on Codeforces. The question was about array cloning (a common problem type involving arrays). I spent a lot of time debugging and perfecting my solution in C++17, only to have it rejected 10 times in a row. To my surprise, when I switched to C++20, the very same code passed without issues.↵
The code is given down below you can check for your self.↵
↵
```cpp↵
#include <bits/stdc++.h>↵
#define ll long long↵
#define pp pair<int, int>↵
using namespace std;↵
↵
int main() {↵
int t;↵
cin >> t;↵
while (t--) {↵
int n;↵
cin >> n;↵
vector<int> v(n);↵
int maxf = 0;↵
unordered_map<int, int> mp;↵
for (int i = 0; i < n; i++) {↵
cin >> v[i];↵
mp[v[i]]++;↵
maxf = max(maxf, mp[v[i]]);↵
}↵
int req = n—- maxf;↵
int step = 0;↵
while (maxf < n) {↵
maxf *= 2;↵
step++;↵
}↵
step += req;↵
cout << step << endl;↵
}↵
}↵
``` ↵
↵
Now, let me share a recent puzzling experience I had while solving a problem on Codeforces. The question was about array cloning (a common problem type involving arrays). I spent a lot of time debugging and perfecting my solution in C++17, only to have it rejected 10 times in a row. To my surprise, when I switched to C++20, the very same code passed without issues.↵
The code is given down below you can check for your self.↵
↵
```cpp↵
#include <bits/stdc++.h>↵
#define ll long long↵
#define pp pair<int, int>↵
using namespace std;↵
↵
int main() {↵
int t;↵
cin >> t;↵
while (t--) {↵
int n;↵
cin >> n;↵
vector<int> v(n);↵
int maxf = 0;↵
unordered_map<int, int> mp;↵
for (int i = 0; i < n; i++) {↵
cin >> v[i];↵
mp[v[i]]++;↵
maxf = max(maxf, mp[v[i]]);↵
}↵
int req = n
int step = 0;↵
while (maxf < n) {↵
maxf *= 2;↵
step++;↵
}↵
step += req;↵
cout << step << endl;↵
}↵
}↵
``` ↵