...with this rate imma be LGM in no more than 201 contests...
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
...with this rate imma be LGM in no more than 201 contests...
congratulations for winning IOI 2024 orzdevinwang
A — Alternating Sum of Numbers
This can be solved in many ways. One of the easiest ways is to use a for-loop and add $$$ a_i $$$ if $$$ i $$$ is odd (1-based indexing) and subtract $$$ a_i $$$ otherwise.
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int32_t main(){
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int ans = 0;
for(int i = 1; i <= n; i++){
int x;
cin >> x;
if(i & 1) ans += x;
else ans -= x;
}
cout << ans << "\n";
}
}
This can be solved using sets and simple conditional statements. There is an interesting solution with $$$ \oplus $$$ (bitwise-xor). Note that $$$ 1 \oplus 2 = 3 $$$. Similarly, $$$ 2 \oplus 3 = 1$$$. Hence, the result is just $$$ a \oplus b $$$.
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int32_t main(){
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int a, b;
cin >> a >> b;
cout << (a ^ b) << "\n";
}
C1 and C2 — Message Transmission Error(Hard Version)
Think of how can we verify if some prefix $$$ i $$$ of string $$$ t $$$ is a valid message or not.
If we're at index $$$ i $$$ in string $$$t$$$, then let $$$ x $$$ be the length of current message. It is nothing but $$$ i + 1 $$$ (0-based indexing). Then we just have to check if prefix of length $$$ x $$$ is equal to suffix of length $$$ x $$$. This can be checked in $$$ O(1) $$$ using String Hashing.
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int getRandomNumber(int l, int r) {
std::random_device rd; // Seed generator
std::mt19937 gen(rd()); // Standard mersenne_twister_engine seeded with rd()
std::uniform_int_distribution<> dis(l, r); // Distribution in range [l, r]
return dis(gen);
}
struct Hash{
int h1 = 0, h2 = 0;
int m1 = 1e9+7, m2 = 1e9+9;
int p;
vector<int> pref1, pref2, power1, power2;
Hash(int base): p(base) {}
void build(string& a){
power1.push_back(1);
while(power1.size() < a.size()){
power1.push_back((power1.back() * p) % m1);
}
power2.push_back(1);
while(power2.size() < a.size()){
power2.push_back((power2.back() * p) % m2);
}
pref1.resize(a.size() + 1, 0ll); pref2.resize(a.size() + 1, 0ll);
int j = 0;
for(int i = 0; i < a.size(); i++){
h1 = (h1 * p % m1 + (a[i] - 'a' + 1)) % m1;
pref1[i + 1] = h1;
h2 = (h2 * p % m2 + (a[i] - 'a' + 1)) % m2;
pref2[i + 1] = h2;
j++;
}
}
pair<int, int> getHash(int i, int j){
int raw1 = pref1[j + 1] - ((pref1[i] * power1[j - i + 1]) % m1);
int raw2 = pref2[j + 1] - ((pref2[i] * power2[j - i + 1]) % m2);
return {(raw1 + m1) % m1, (raw2 + m2) % m2};
}
};
int32_t main(){
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
string s;
cin >> s;
int n = s.size();
int base = getRandomNumber(55, 1e8);
Hash hash(base);
hash.build(s);
int ans = -1;
for(int i = 0; i + 1 < n; i++){
int len = max(n - i - 1, i + 1);
if(len == i + 1) continue;
pair<int, int> pref = hash.getHash(0, len - 1);
pair<int, int> suff = hash.getHash(n - len, n - 1);
if(pref.first == suff.first && pref.second == suff.second){
ans = len - 1;
break;
}
}
if(ans == -1) cout << "NO" << "\n";
else{
cout << "YES" << "\n";
for(int i = 0; i <= ans; i++) cout << s[i];
}
}
Also if someone has solved C1 and C2 with KMP, please explain your solution.
As I said, here's the screencast for edu codeforces round 169. i'm fully committed to my previous apology blog
Here's the screencast for codeforces round 967(div. 2)
Hello codeforces,
In this blog, I wanna admit my cheating and bad behaviour in my competitive programming career on codeforces. With greed of rating and pressure of rating, I've cheated sometimes. My original account was Wasif_Shahzad. It got skipped some times(4-5 ig). I was really sorry about my behaviour and decided to abandon that account.
In the last AtCoder Beginner Contest, I used ChatGPT to solve problem B in which I got stuck on in implementation. I didn't know the rule change of atcoder. I'm really sorry to atcoder community for that. I promise that I will never use chat GPT in ABCs.
Also Recently, I've got some public accussations under the announcemet blog of recent div. 3 contest. I've read the whole thread now and came to know some people think I cheated cuz I got hacked on E. There was some discussion on errichto discord server and people were saying I cheated YET again in yesterday's contest. I felt very bad and decided to leave the server finally because some people were requesting the mods to ban me. Let me clarify what happened yesterday. I saw hacks and saw a submission which got hacked and had that SPECIAL CASE. I asked chat GPT to generate a case for me which would work. Then I wanted to check if that would work or no. so I submitted the code from my account and then hacked that submission myself. You can see the submission times and that I hacked it myself. Moreover, it doesn't make any sense to cheat after the contest is over.
I've decided that from now on, I'll record every contest and publish it on YouTube to be on safer side.
I request MikeMirzayanov to ban the account Wasif_Shahzad please. I promise I'll never be in anything like this again and lastly, I hope that the community will accept my apology.
UPDATE: I legit forgot to write about the d2 incident where I got FST. I'm really serious about my behaviour. I wouldn't have written this blog and exposed myself if I weren't being honest. I'm really really sorry again. The decision is of the community now.
Next year is my last chance for IOI and I wanna give my best to get there. I'm facing a few issues and want to ask for help.
I face a very hard time when facing mathematical problems regarding number theory and mathematics and their proofs. The only proof I know about is PROOF BY AC. other than that, I don't know anything but sometimes it isn't good. I think I need to develop it on mathematics side and if someone knows some sort of website like Codeforces where I can practice my proving skills a.k.a. basic practice for IMO please tell in comments. My goal is to NOT go to IMO but I think that would help a lot.
My current practice rating on codeforces is 1600. I'm planning to solve the entire first page of problemset of 1600(in ascending order). I also wanna grind OI problems because they're quite different from cf problems. The only website I know is qoj.ac on which I find the problems very hard so I'd like if someone knows any website/cf group from where I can start from easy OI problems, please let me know in comments.
Additional info: for some reason I find USACO bronze very hard and I couldn't even solve a single problem in US Open so that's why I don't usually practice there.
Should I change my mind and grind that instead of codeforces?
I'm very serious about my dedication. Even though I have like 7-8 months for next year's IOI team selection, I'm ready to practice with full zeal and zest.
Thank you!
As we all know physical activities are super important along with competitive programming and other computer related things. What do you do then? I personally like to play cricket and football. Also I go for jogging with my friend on a racetrack everyday.
Name |
---|