Thank y'all so much for participating!
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int ans = 0;
for (int i = 0; i < n / k; i++) {
bool has_non_nhoj_farm = false;
for (int j = i * k; j < (i + 1) * k; j++) {
if (s[j] == '0') has_non_nhoj_farm = true;
}
ans += !has_non_nhoj_farm;
}
cout << ans << "\n";
}
}
When comparing two numbers that are initially not equal, the only way they can become equal after some number of operations is if at least one of them has an operation performed on it when it is $$$ \lt 2$$$.
If two elements are equal at some point, they'll be equal no matter how many more operations are performed. Therefore, it suffices to look at the end behavior of each element.
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vec(n); for (auto &x: vec) cin >> x;
int mod_4[] {0, 0, 0, 0};
for (auto &x: vec) mod_4[x%4]++;
cout << max({mod_4[0], mod_4[2], mod_4[1] + mod_4[3]}) << "\n";
}
}
If a $$$-1$$$ is in between two $$$1$$$s, it would only hurt the answer to make it a $$$1$$$.
If a $$$-1$$$ is not in between two $$$1$$$ s, the $$$-1$$$ would only be included in a subarray satisfying the conditions if it was an endpoint.
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vec(n); for (auto &x: vec) cin >> x;
for (int i = 0; i < n; i++) {
if (vec[i] == -1) vec[i] = 1;
if (vec[i] == 1) break;
}
for (int i = n-1; i >= 0; i--) {
if (vec[i] == -1) vec[i] = 1;
if (vec[i] == 1) break;
}
for (auto &x: vec) cout << max(x, 0) << " ";
cout << "\n";
}
}
If there is only one $$$0$$$ in the array, then exactly one set will have a mex greater than zero
$$$MEX(A) = MEX(B), MEX(C) = 0$$$ satisfies the constraints.
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vec(n); for (auto &x: vec) cin >> x;
if (count(vec.begin(), vec.end(), 0) == 1) {
cout << "NO\n";
continue;
}
cout << "YES\n";
bool seen_zero = false;
for (int i = 0; i < n; i++) {
if (vec[i] != 0) cout << 'A';
else if (seen_zero) cout << 'B';
else {
seen_zero = true;
cout << 'C';
}
}
cout << "\n";
}
}
2259E - Treasure Map Destruction (Constructive Version)
If an element $$$x$$$ at index $$$i$$$ is not equal to $$$-1$$$, there must be a treasure at either island $$$i + x$$$ or $$$i - x$$$
If an element $$$x$$$ at index $$$i$$$ is not equal to $$$-1$$$, there must no treasures in the exclusive range of indices ($$$i + x$$$, $$$i - x$$$)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vec(n); for (auto &x: vec) cin >> x;
vector<int> diff(n+1);
for (int i = 0; i < n; i++) {
if (vec[i] > 0) {
diff[max(0, i-vec[i]+1)]++;
diff[min(n, i+vec[i])]--;
}
}
vector<bool> restricted(n);
int curr_count = 0;
for (int i = 0; i < n; i++) {
curr_count += diff[i];
restricted[i] = curr_count > 0;
}
bool possible = true;
for (int i = 0; i < n && possible; i++) {
if (vec[i] >= 0) {
if (i - vec[i] >= 0 && !restricted[i - vec[i]]) continue;
if (i + vec[i] < n && !restricted[i + vec[i]]) continue;
possible = false;
}
}
if (!possible) cout << -1 << "\n";
else {
for (auto x: restricted) cout << !x;
cout << "\n";
}
}
}
2259F - Binary Bubble Sort Inversions
Look at performing some bubbles and reverse bubbles on small arrays. How many elements are moved?
A bubble will result is the leftmost 1 being moved all the way to the right. Similarly, a reverse bubble will result in the rightmost 0 being moved all the way to the left.
Since prefix zeroes and suffix ones don't matter, if we continuously remove them, then a bubble removes the last element of the array and a reverse bubble removes the first element of the array. Is there a way to remove the first and last elements of an array in constant time?
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vec(n); for (auto &x: vec) cin >> x;
string s;
cin >> s;
ll inversions = 0;
int cnt_ones = 0;
for (int i = 0; i < n; i++) {
cnt_ones += vec[i];
if (vec[i] == 0) inversions += cnt_ones;
}
cout << inversions << " ";
deque<int> dq;
for (auto &x: vec) dq.push_back(x);
int cnt_zeroes = count(vec.begin(), vec.end(), 0);
for (int i = 0; i < n; i++) {
while (dq.size() > 0 && dq.front() == 0) {
dq.pop_front();
cnt_zeroes--;
}
while (dq.size() > 0 && dq.back() == 1) dq.pop_back();
if (dq.size() == 0) {
cout << 0 << " ";
continue;
}
if (s[i] == '0') {
inversions -= (dq.size() - cnt_zeroes);
dq.pop_back();
cnt_zeroes--;
}
else {
inversions -= cnt_zeroes;
dq.pop_front();
}
cout << inversions << " ";
}
cout << "\n";
}
}
Ignoring indexes 1 and $$$n$$$, if we remove index $$$i$$$, if we perform an operation on index $$$j$$$, all elements between $$$[i, j]$$$ will also have an operation performed on them.
If we remove index $$$i$$$, and we have to reduce the element at index $$$i+1$$$, $$$i+2$$$, etc, what will we subtract it to?
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int t;
cin >> t;
while (t--) {
ll n, k;
cin >> n >> k;
vector<ll> vec(n); for (auto &x: vec) cin >> x;
vector<ll> vec_2(n); for (int i = 0; i < n; i++) vec_2[i] = vec[i] - i * k;
vector<ll> prefix(n); prefix[0] = vec[0];
for (int i = 1; i < n; i++) prefix[i] = prefix[i-1] + vec[i];
vector<ll> ans(n);
for (int i = 1; i < n-1; i++) {
int lo = i+1;
int hi = n-1;
while (lo <= hi) {
int mid = lo + (hi - lo) / 2;
if (vec_2[mid] <= (vec[i-1] - i*k)) hi = mid - 1;
else lo = mid + 1;
}
ll num_needed = (lo - i - 1);
ans[i] = (prefix[num_needed + i] - prefix[i]) - (k * (num_needed * (num_needed + 1))/2) - vec[i-1] * num_needed;
}
for (auto &x: ans) cout << x << " ";
cout << "\n";
}
}
2259H - Treasure Map Destruction (Counting Version)
Read the solution to problem E first
Let's consider all locations that we have not restricted: we can separate them into 3 categories: the position is forced to be a treasure, the position has no undestroyed that depend on it, and all other positions.
The islands that are considered "non-restricted" form a chain of locations, with each non-restricted chain having a treasure between them. What must be true of the locations in this chain such that no condition is violated?
For every pair of adjacent locations, there must be at least one treasure at one of those locations.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const int MAX_N = 200055;
int main() {
int t;
cin >> t;
vector<ll> fibo(MAX_N);
fibo[1] = 1;
fibo[2] = 1;
for (int i = 3; i < MAX_N; i++) {
fibo[i] = (fibo[i-1] + fibo[i-2]) % MOD;
}
while (t--) {
int n;
cin >> n;
vector<int> vec(n); for (auto &x: vec) cin >> x;
vector<int> diff(n+1);
for (int i = 0; i < n; i++) {
if (vec[i] > 0) {
diff[max(0, i-vec[i]+1)]++;
diff[min(n, i+vec[i])]--;
}
}
vector<bool> restricted(n);
vector<bool> forced(n);
vector<int> non_required;
int curr_count = 0;
for (int i = 0; i < n; i++) {
curr_count += diff[i];
restricted[i] = curr_count > 0;
}
bool possible = true;
for (int i = 0; i < n; i++) {
if (vec[i] != -1) {
int cnt = 0;
cnt += (i - vec[i] >= 0 && !restricted[i - vec[i]]);
cnt += (i + vec[i] < n && !restricted[i + vec[i]]);
if (cnt == 0) { possible = false;}
if (cnt == 1 || vec[i] == 0) {
if (i + vec[i] < n) forced[i + vec[i]] = true;
if (i - vec[i] >= 0) forced[i - vec[i]] = true;
}
}
}
for (int i = 0; i < n; i++) {
if (!restricted[i] && !forced[i]) non_required.push_back(i);
}
if (!possible) {
cout << 0 << "\n";
continue;
}
ll total = 1;
int chain_len = 1;
for (int i = 0; i < non_required.size(); i++) {
bool cond1 = i == non_required.size() - 1 || vec[(non_required[i] + non_required[i+1])/2] == (non_required[i+1] - non_required[i])/2;
bool cond2 = i == non_required.size() - 1 || (non_required[i+1] - non_required[i]) % 2 == 0;
//if (i != 1) cout << (non_required[i+1] - non_required[i]) << "\n";
if (i == non_required.size() - 1 || !cond1 || !cond2) {
//cout << chain_len << "\n";
total *= fibo[chain_len+2];
total %= MOD;
chain_len = 1;
}
else chain_len++;
}
if (count(vec.begin(), vec.end(), -1) == n) {
total = (total + MOD - 1) % MOD;
}
cout << total << "\n";
}
}








Auto comment: topic has been updated by nik_exists (previous revision, new revision, compare).
where are codes
it only have
cppWait until the hack end
Code has been added!
OK
good contest!
tysm!
TIGER! TIGER!........
felt that problem F was more trickier than problem G!
nice round thanks !
tysm!
good problems, C was kind of annoying to implement
I personally think C wasn't so annoying
Amazing round. Ty king
tysm!
Maybe you are missing the space after
[tutorial:2259B]?It works for me:
nik_exists
yep, that was it, thank you so much!
Also, there are no code in the editorial
W contest
2259E code ... cpp :skull:
model actually isn't that long
The editorial isn't working because it doesn't use the announcement format /j
C is harder than D. But still orz round by nik_exists
For me D is harder
Here is my two agree
E can be solved with 2-SAT
Can you explain more
Lets forget about the -1 for a moment cause they dont really matter at all in problem E. Just some border cases.
We want i-A[i] or A[i]+i to be '1' in our string ans.
When both i-A[i] or A[i]+i fits in the array we can choose any of them, can be both or exactly one. (.either() method in the code)
When only one of them fits in the array it must be equal to '1' in our ans (SetValue method in the code)
When neither of them fits theres no answer
The conditions above are not suficient as we have to ensure in the range [i-A[i]+1,i+A[i]-1] there are no 1's in our solution. The way to solve this is an array diference to know the unvalid positions. SetValue(-i)
Explain deeper how to solve the range [i-A[i]+1,i+A[i]-1] without getting TLE
The main idea in the array diference is to simulate a assignment in ranges.
We want to put in our array 'p' on the range [i-A[i]+1,i+A[i]-1] a 1 to know this range is unvalid. Instead of iterating over the range (because TLE) or having a Lazy Segment Tree, we can sum a 1 in the begining of the range and a -1 immediately after the range. Then do a prefix sum and the array going to become the desire one.
Do some cases to convice yourself
Thanks,it's a nice explanation :)
I did it using stacks and queue
Intialize the array ans of size n which are all 1 intialize the queue with {2,3,4.....n} intialize empty stack
for i in 1,2,3 .... n if a[i] > 0 then ans[i] = 0
after the loop just check if ans is a valid answer
intuition behind this is that stack allows you to look at indexes from right to left(but less than i) which were not forced to be zero before and queue let's you look at indexes from left to right (>i) which were not forced to be zero before.
i thought of 2SAT and then went for other solution (because i think we don't need 2SAT at all).
Basically if a[i] == 0, then there should be treasure at position i. Otherwise if a[i] > 0, there should be a treasure at i — a[i] OR i + a[i]. So you just need to add a OR clause and let 2SAT solve it.
if i — a[i] <= 0. Then i + a[i] MUST be treasure. if i + a[i] > n. Then i — a[i] MUST be treasure. otherwise either of them can be a treasure.
It Was a fun contest , but i got struck at E for almost the whole contest :-(
I cared too much about my rating. That's why I wanted to solve C as fast as I could and made many silly mistakes
Felt that.Same thing happened to me on D
Thanks for the contest! I enjoyed it
should i try to upsolve E? current rating is 1072 and max is 1100.
Yes
Nice contest!
i dont know why i found it hard to understand E statement otherwise amazing round!
Please elaborate more on the editorial of $$$E$$$.
let the given array be v and the final string be s for each v[i]>0 the closest island to it should be at position i-v[i] or i+v[i] if there is an island (v[j]=0) in the range ]i-v[i],i+v[i][ then that element j will be closer to v[i] which will be a contradiction so you should output -1 then for each -1 outside of the union of these ranges you can consider it as an island (set it to 1 in s and its valid given that it does'nt influence other elements) the -1 inside the union of the ranges will be set to 0 in the final string because they cant be set to 1 after that you need to check for every element i with v[i]>0 if there is an island in i-v[i] or i+v[i]
[commented twice by mistake]
how to check in a range if there is $$$0$$$ while updating $$$i+v[i]$$$ or $$$i-v[i]$$$ to $$$0$$$ greedily? because if we dont greedily assign 0 to left side or right side then some other index might contradict previous indices.
you should do the check before changing -1 to 0 check my code maybe you'll understand it better 389559260
first we need to rule out the points where treasures definitely can't be
for this we can use the idea of difference arrays basically if we want to mark some subsegment as invalid we do sum[l]++ and sum[r + 1]-- (think about this if you didn't know it)
to find the value at point i we need the prefsum from sum[0] + sum[1] ... + sum[i]
now we find the values where a treasure could be placed (these are the points that aren't blocked at all) and check for each index that isn't -1 whether these 0s are at the required distance, otherwise no solution
The problems were amazing and realized I need to improve myself, java was kind of problematic at times
Why does the system testing so long?
good contest, but G is too easy in Div.3
I liked this round a lot, but B felt easier to implement than A xd. And G was really easy compared to E for me.
Good work!
E took me longer than F and almost had G on time but still it was a great round!
Amazing contest, A-D was very easy.The jump from D to E was pretty big for a div 3.
Question F was really fun!
i got WA on test case 2 which was n=3 -1 1 1 i got answer as 1 0 0 Placing a treasure at island 1 (100) gives: Distance from island 1 to nearest treasure = 0. Distance from island 2 to nearest treasure = 1 (which is >=1). Distance from island 3 to nearest treasure = 2 (which is >=1). As question has clearly stated that ai means treasure is 'ATLEAST' distance away from ith island so my answer should be valid why jury's answer is -1
nik_exists explain this
As question has clearly stated that ai means treasure is 'ATLEAST' distance awaythis is not what the question says
ai indicates the minimum number of islands that Bessie would need to travel throughThe minimum distance that Bessie would have to travel from Island 3 to reach a treasure is 2, not 1
so 'minimum' no of islands that bassie would need to travel from island 3 to reach treasure is should be 1 .. in my solution it is 2 which is (>=1) i think that meaning is also valid it should be accepted also please do consider this perpective as well.
nik_exists
if the questions asks for the minimum and you give an answer greater than the minimum your answer is wrong
ai indicates the minimum number of islands that Bessie would need to travel through
so Bessie has travlled minimum distance of ai so it should be valid .. i don't care about getting accepted but just think of this sentence and valid solution for it .. if we wanted that distance to be exactly ai we should have mentioned it that
ai indicates the exact number of islands that Bessie would need to travel through to get treasure
nik_exists
The minimum distance Bessie would have to travel in your answer is 2 islands. This does not match the array a, which requires the minimum distance be 1 island, so it is not a valid solution
ai indicates the minimum number of islands that Bessie would need to travel through
This means, ai is equal to(=) min number of islands travelled
Not min dist of ai
the distance of the nearest treasure from j should be exactly b[j] (if b[j] is not -1). not >=b[j]
where did it mentioned 'exactly' brooo it says minimum ai that means it can be greater than ai aslo but minimum ai so i solved it like that..
nik_exists
Agree, how is everybody here under mass psychosis, it says minimum distance not EXACT distance
the minimum distance (i.e. shortest path) between two positions in an array is $$$\lvert i - j \rvert$$$
AMAZING E and F! I had a lot of fun solving them :3
Have fun got them skipped?
man i thought you were legit :(
I see, U had lot of fun XD
My contest discussion stream here for ABCDEFG
.
btw which AI u used during contest. seems pretty dumb.
im trainning for ICPC so now im practicing mostly on thinking harder problems, i mostly implement the problems, sometimes i really on IA but just for a little bit of help in implementation
DNR
as im seeing in the rules this is allowed, i didnt write the core logic with AI, and ever let AI think a problem for me, i know that this will be cheating and its bad.
Fantastic round, enjoy it
In $$$G$$$ the last-moving index will always increase, so it can be done in $$$O(n)$$$ with two-pointers rather than binary search. (I found it easier to think in terms of the "slack", $$$k-(a_{i+1}-a_{i})$$$ equivalently you are finding the position at which the total slack from your current position hits $$$k$$$; the fact this increases is then immediate from the slack always being positive).
https://codeforces.me/contest/2259/submission/389601071 is this $$$O(n^2)$$$?upd: hacked
I tried to construct the graph in H and do some kind of DP on it, but I got stuck in the cycles part... It took me a while to realizes the graph's cycles has a special structure: they are disjoint segments and all edges in the cycles already has their 0/1 values. At that point, I just needed to prune the cycles to do DP.
After solving F and G post contest, i think F<G<E. Aside from getting cooked by E, really great contest!
the markdown formatting is incorrect. Here’s the code for problem E in case anyone needs it :33
during the event i solved 4 questions i thought my rating would be 1050+ but due to the checkbox i didnt read it and i participated in unrated contest.THE FEELING cant be described :(
What would be the approximate rating for all the problems? I gave this contest after around 6 months of inactivity and solved 4.
Hello nik_exists,
This letter is about my skip from the contest.
First, I want to make clear that I didn’t cheat or use any external programs during the competition. I made my solutions by myself relying only on my knowledge.
Of course, the anti-cheat can find some similarities or something strange, and I fully understand the necessity of this measure. Nevertheless, I think that I was flagged by mistake.
If there was something in my code which attracted your attention, I will be grateful if you could tell me what it was. Besides, I am fully ready to explain my solutions and every line of my code so that you could see that I understood everything by myself.
Thank you for your consideration.
nik_exists
nik_exists
Amazing round, I enjoyed it , thanks a lot
Nice contest
What a contest man! Got to learn many things. Thank you!!
Can anyone help me, i solved a-e in this contest but all my submissions are skipped and i got a message that it was due to some violation in rule. here are my submissions 389498525,389511176,389531255,389539799 i don't understand why they are skipped but they seems fine to me.
I have the same issue. Please someone look at this.....and mine as well
nice , thanks for this useful contest =)
Heyy..I gave the whole contest fairly but today I received the message "your responses are not being considered due to rule violations". Can anyone tell why I got this? I didn't cheat at all.
nik_exists please look at this.
Bro......I just checked the AI flagged solutions for all codes and in code e, just the name treasure_map_fin matches, that is a pure coincidence. The logic was really simple for the problem and that's what I did step by step...find the possible indices, if none is possible flag as -1, check for exact presence......just the name of vector got same
Could you please tell me what the violation notice looks like on your side? I performed well in this contest, but my rating did not change — it seems my participation was skipped. I did not receive any notification explaining why. Is it possible that I just do not know where to find the violation information?
You're asking someone that went extinct to reply to you?

Also, you registered as unrated in the contest
Oh, I see! I’m truly sorry for the trouble caused by my own mistake.
first time solved 4 problems yeeepie but after the contest got a runtime error on c but still happy
can someone explain why TLE ?389511024 and here where went wrong ? 389560130
1-Fast I/O: Use sys.stdin.read().split() instead of input().split(). Reading input line by line in multiple test cases is very slow.
2-Hash Collisions: In Codeforces, Python's dict and Counter are vulnerable to anti-hash tests. Hackers can force hash collisions that degrade operations from $$$O(1)$$$ to $$$O(N)$$$, causing an $$$O(N^2)$$$ TLE.
3-Unnecessary Dict: In your codes, for example, in the second code you don't need Counter at all since you only count zeros (using arr.count(0) or a basic loop).
nice contest! code?
My alternative solution for Problem H (no 2-sat, dsu required):
1) A valid treasure placement configuration must follow a specific zig-zag pattern:
- It starts with a strictly decreasing sequence (step -1) down to $$$0$$$.
- Then, it strictly increases (step +1).Then, it strictly decreases (step -1) back to $$$0$$$.
- This pattern alternates, ending with a strictly increasing sequence.
- At the transition points (the "peaks" and "valleys" between segments), the absolute difference between adjacent elements cannot exceed 1.
- Example of a valid configuration:
3 2 1 0 1 2 3 4 5 4 3 2 1 0 0 1 2 2 1 0 1 2 3 4.2) Since each valid configuration corresponds to a distinct placement strategy, the problem reduces to counting the number of ways to replace all (-1)s with non-negative integers such that the resulting array satisfies the conditions above.
3) For each index $$$i$$$ from $$$1$$$ to $$$n$$$:
- Define $$$L[i] = k$$$ as the maximum length $$$k$$$ extending to the left of $$$i$$$ such that this segment can be validly filled as a strictly decreasing sequence from $$$k-1$$$ down to $$$0$$$. This can be computed using Binary Search + Sparse Table.
- Similarly, define $$$R[i] = k$$$ as the maximum length $$$k$$$ extending to the right of $$$i$$$ such that this segment can be validly filled as a strictly increasing sequence from $$$0$$$ up to $$$k-1$$$. This can also be computed using Binary Search + Sparse Table.
4) Let $$$dp[i]$$$ be the number of valid ways to fill the prefix from $$$1$$$ to $$$i$$$, given that $$$a[i] = 0$$$.
- Obviously, if $$$a[i] \gt 0$$$, then $$$dp[i]=0$$$.
- If the prefix is just a single decreasing sequence down to $$$0$$$, then $$$dp[i] = 1$$$ if $$$L[i] = i$$$, otherwise $$$0$$$.
- For other valid configurations, $$$dp[i]$$$ is the sum of $$$dp[j]$$$ for all $$$1 \le j \lt i$$$ where the gap between $$$j$$$ and $$$i$$$ can form a valid "mountain" (an increasing segment followed by a decreasing segment). The condition for this is $$$\min(L[i], R[j]) \ge \lceil \frac{i - j + 1}{2} \rceil$$$, which can be rewritten as: $$$2 \times \min(L[i], R[j]) \ge i - j + 1$$$. This can be optimized from $$$O(n^2)$$$ to $$$O(nlogn)$$$ by using CDQ or Sweepline.
- If $$$R[i] = N - i + 1$$$, it means the remaining suffix (from $$$i$$$ to $$$N$$$) can be formed as a strictly increasing sequence starting from $$$0$$$. Thus, this $$$dp[i]$$$ contributes to the final answer.
5) Code: https://codeforces.me/contest/2259/submission/389626088
Why is there no code?
I failed E purely for the reason of misunderstanding this line " a[i] ** indicates the minimum number of islands that Bessie would need to travel** ". I thought it meant that treasure can exist anywhere other than range i-a[i]+1 and i+a[i]-1. Hate myself.
Great contest, hope more like this one :)
nice contest, learn a lot tysm
honestly, problem A was harder than B, what do you think?
bullshit problems
Hello, I participated in this contest as an official contestant (handle: SXWisON). I solved 8/8 problems and finished around rank 15, but I am not in the rating changes list and my rating is still 1325. Could you please check if my rating update was missed? Thank you.
solution to G using two lazy segment trees
in both rounds I've set, half the problems had unintended segtree solutions... (in my div4 D, E, F, and H, in this one, E, F, G, and H)
just gave it as virtual, great contest keep up the great work <3
Can we demonstrate the correctness of the solution for problem D?
D is interesting but a bit difficult for me.
Problem E was a good one. Really enjoyed solving it!
F is easier than E !!!!
thanks for the editorial
It seems editorial solution for 2259C is not correct. It is giving wrong output for this case: 7 -1 0 1 -1 0 0 1
output: 1 0 1 0 0 0 1
expected output: 0 0 1 0 0 0 1
There can be multiple possible answers, in this case both have a score of 5