### yash_daga's blog

By yash_daga, history, 12 days ago,

We invite you to participate in CodeChef’s Starters134, this Wednesday, 15th May, rated for till 6-Stars(ie. for users with rating < 2500).

One of the problems of this contest was also used in Code Mania Blitz, ancc IITD contest, so if you participated in that contest, please refrain from participating.

Joining us on the problem setting panel are:

Note: Some problems have subtasks

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here. Hope to see you participating.

Good Luck!

• +63

 » 11 days ago, # |   -8 C++23 when
 » 10 days ago, # |   +22
 » 10 days ago, # |   +18 How on earth have so many people solved COUNTRBS? My solution is to notice that at most one good RBS starts at each position (namely, it ends at the next occurrence of the same prefix sum if all prefix sums in between are greater) and hash all O(n) substrings, but I think the observation part is too hard for most 5* coders.
•  » » 10 days ago, # ^ |   +3 I think it's scoreboard effect and the fact that you don't need to think about prefix sums. Simply find matching brackets in the string (as the string itself is a regular bracket sequence), and use your favourite way to compare two substrings.
 » 10 days ago, # |   +1 why WA in 3in1out#include using namespace std; char nl = '\n'; using i64 = long long; struct fenwick { vector bit; int n; fenwick(int sz) { n = sz; bit.resize(sz); } void upd(int i, i64 d) { while(i < n) { bit[i] += d; i |= (i + 1); } } void build(vector& A) { for(int i = 0; i < n; i++) { upd(i, A[i]); } } i64 sum(int r) { i64 ans = 0; while(r >= 0) { ans += bit[r]; r = (r & (r + 1)) - 1; } return ans; } i64 get_sum(int l, int r) { return sum(r) - sum(l - 1); } }; void solve(int t) { // cout << "test #" << t << << nl; int n, q; cin >> n >> q; vector A(n); i64 tot = 0; for(auto& a : A) cin >> a, tot += a; map> idx; vector aux = A; sort(aux.begin(), aux.end()); for(int i = 0; i < n; i++) { idx[aux[i]].push_back(i); } fenwick fen(n), cnt(n); for(int i = 0; i < n; i++) fen.upd(i, aux[i]); for(int i = 0; i < n; i++) cnt.upd(i, 1); auto ask = [&](int x) -> int { int s = 0, e = n - 1; int ans = 0; while(s <= e) { int mid = (s + e) >> 1; int cur = cnt.sum(mid); if(cur <= x) { ans = mid; s = mid + 1; } else e = mid - 1; } return ans; }; vector ans(n); for(int i = n - 1; i >= 0; i--) { if(i % 2 == 0) { int j = ask(i / 2); ans[i] = tot - (2LL * fen.sum(j)); } tot -= A[i]; cnt.upd(idx[A[i]].back(), -1); fen.upd(idx[A[i]].back(), -A[i]); idx[A[i]].pop_back(); } while(q--) { int k; cin >> k; cout << ans[--k] << " "; } cout << nl; } int main() { int tt = 1; cin >> tt; for(int t = 1; t <= tt; t++) solve(t); } 
 » 10 days ago, # |   +5 Boring Contest ever
 » 10 days ago, # |   0 Very bad contest, question were some variation of standard problems. ( div2B or div2C)Also there is issue with cc contest timer, i had 7 minutes remaining acc. to timer but when i submit my code it displayed time over.this happend multiple times, resulting in me losing rank. please fix it :(
 » 10 days ago, # |   0 why there is only one sample case. If you are so insecure of people guessing the solution by looking at test cases than why create such guessable problems
•  » » 10 days ago, # ^ |   +18 In case you are talking about Permutation Cycle Queries. My OpinionIn my opinion purpose of sample cases are for contestants to verify if they understood th problem statement correctly or not, I dont think it has anything to do with guessing or not. If one sample case serves the purpose then it should be fine.
 » 10 days ago, # |   +18 In PRISON it should be made more clear what to output when there are no prisoners or guarenteed that there is at lease one prisoner. I chose some random negative values and got WA first.
 » 10 days ago, # |   +21 Great Problemset. I learned alot.
 » 10 days ago, # |   +8 3outin1 had me..loved this one
 » 10 days ago, # | ← Rev. 2 →   +8 What a creativity in writing countRBS problem, really awesome. I mean doable with both string hashing and tree hashing