### Nocturnality's blog

By Nocturnality, 6 weeks ago,

Hello Codeforces!

I organized a contest at my university in November 2023, and I'm happy to welcome all of you to participate virtually or solve the problems later on.

Contest link: Intra Department Programming Contest, CSE-BU

There are 8 problems and 150 minutes to solve them. Problems are not sorted by difficulty order. I recommend you to read all the problems.

This problemset were create for users with a rating range from 0 to 1400 but anyone welcome to participate virtually or upsolve the problems!

I would like to thank everyone who was involved in the contest preparation:

I tried my best to keep the statements short and clear and I hope you will like the problemset!

Happy Coding!

• +32

 » 6 weeks ago, # | ← Rev. 2 →   0 what's wrong with this F WA 6#include using namespace std; char nl = '\n'; using i64 = long long; vector prime(1e7 + 1, true); vector pref(1e7 + 1); void sieve() { prime[0] = prime[1] = 0; for (i64 p = 2; p * p <= int(1e7); p++) { if (prime[p] == true) { for (i64 i = p * p; i <= int(1e7); i += p) prime[i] = false; } } } void solve(int t) { // cout << "test #" << t << << nl; int l, r; cin >> l >> r; cout << pref[r] - pref[l - 1] << nl; } int main() { sieve(); for(int i = 2; i <= int(1e7); i++) { pref[i] = pref[i - 1]; if(prime[i] && prime[i - 2]) pref[i]++; } int tt = 1; cin >> tt; for(int t = 1; t <= tt; t++) solve(t); } 
•  » » 6 weeks ago, # ^ |   +1 I used the exact same code but, for prefix, used an array instead of vector. Got AC. Code#include using namespace std; char nl = '\n'; using i64 = long long; vector prime(1e7 + 1, true); int pref[(int) 1e7 + 1]; void sieve() { prime[0] = prime[1] = 0; for (i64 p = 2; p * p <= int(1e7); p++) { if (prime[p] == true) { for (i64 i = p * p; i <= int(1e7); i += p) prime[i] = false; } } } void solve(int t) { // cout << "test #" << t << << nl; int l, r; cin >> l >> r; cout << pref[r] - pref[l - 1] << nl; } int main() { sieve(); for(int i = 2; i <= int(1e7); i++) { pref[i] = pref[i - 1]; if(prime[i] && prime[i - 2]) pref[i]++; } int tt = 1; cin >> tt; for(int t = 1; t <= tt; t++) solve(t); } 
•  » » » 6 weeks ago, # ^ |   0 Thanks! can you explain why using vector gives WA
•  » » » » 6 weeks ago, # ^ | ← Rev. 3 →   +1 It's actually not your fault. Constraints clearly show that 1 ≤ l, but test 6 actually has l less than 1. I tried using using .at() function instead of [] and got runtime error, while using pref[max(l — 1, 0)] passed.
•  » » » » » 6 weeks ago, # ^ |   0 Thank you so much!
•  » » » 6 weeks ago, # ^ | ← Rev. 5 →   0 forIoop Thanks for your help. I've sorted out the constraints and test cases, so everything should be fine now.
•  » » 6 weeks ago, # ^ |   0 alpha1215 You have to consider the case when L=0.Unfortunately I missed the constraints (0 $\le$ L). Now I fixed it and everything alright.
 » 6 weeks ago, # | ← Rev. 2 →   +4 Nice contest, though I do feel it's still easier than regular Div.4. Thoughts and feedbacks from an outsiderThe contest feels a bit math-heavy. I do feel like it could have covered a few more algorithmic topics than this, E is a bit unnecessary (I meant, I might be in the dark, but who are the participants of this contest to have a HelloWorld-like problem? If they are freshmen, then sure, it's acceptable), but overall the maths weren't so bad.Speaking of E, I was kinda confused at first as the statements and the outputs didn't really linked together. The backstory seemed to imply us to try spelling Exactly, while the actual output is a different story.Problem constraints seemed a bit inconsistent. B could have had $n \le 2 \cdot 10^5$ without harming the intended solution. And why did D have $n \le 10^6$? I don't get the idea of what you're trying to block with this constraints, but AFAIK, the most braindead solution for D is a very high coefficient STL-based $\mathcal{O}(n \log n)$ — and it still worked just fine here. It could have been $2 \cdot 10^5$ and thus removing the hassle of fastio.Problem statements could have made use of LaTeX more. I think the writer just learnt it recently, and could only apply it sparsely and yet without a regulation of when to use those. It's alright, it didn't harm the overall readability, but I hope they could do better next time.The rest is standard educational stuff, so I don't have much to comment.At any rate, I really appreciated these contents, regardless of how basic they are. After all, newbies tend to need those building blocks the most.UPD: Edited recommended constraints to $2 \cdot 10^5$ because sometimes weird pragmas actually pushed $\mathcal{O}(n^2)$ bruteforce past 1s TL if $n \le 10^5$ only.
•  » » 6 weeks ago, # ^ | ← Rev. 3 →   0 This is my first setted contest in CF. Most of the participants were freshman. That's why I had to do it and setted a problem like E. I already fixed all of the constraints in the problemset. AkiLotus Thanks a lot for your valuable suggestions.
 » 6 weeks ago, # |   +1 Good Initiative.
 » 6 weeks ago, # |   0 Thank you for setting this up, it was fun to do. My short feedback would beto pay a little bit more attention to making the problem statements clearer. For instance when I first read F, I thought that we are looking for numbers that are sums of three different primes, like 2+3+5 for instance. Also in problem G the third rule should have been "The absolute difference between number of tasks of consecutive two days is one".Other than that I feel the problem set was varied enough in difficulty and style for the intended audience.
•  » » 6 weeks ago, # ^ |   0 SleepyOverlord Thanks for your feedback.
 » 5 weeks ago, # |   0 why in C just sorting and returning square of min of 4 max elements gives WA on test 15