Codeforces|Leetcode|Codechef free solutions
Open in Telegram
Free codeforces, Codechef, Leetcode solutions are available 😍😍😍😍😍😍 Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. 🥳🥳🥳🤩🤩🤩 Dm @Cpsoln if you want help in coding round.
Show more4 317
Subscribers
No data24 hours
-137 days
-5230 days
Posts Archive
If anyone wants to sell codeforces expert or specialist id dm me
YESS WE DID IT AGAIN 🤩🔥❤️.
India Won Against Pakistan 🙌
#8-1
*Proud Moment 😍🥳💯
Share our channel we will post more free solutions in upcoming contests🥳🥳
#include<bits/stdc++.h>
using namespace std;
#define y1 as214
#define ii pair < ll , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >
#define fi first
#define se second
#define fr front()
#define pb push_back
#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define ll long long
#define oo 1e7
#define int long long
const int N = 1e6 + 5;
int q , n , mod = 998244353;
int a[N] , f1[N] , f2[N] , w1[N] , w2[N];
main()
{
//freopen("gen.inp","r",stdin);
//freopen("COLORS.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cin >> q;
while(q--)
{
cin >> n;
for(int i = 1 ; i <= n ; i++)
cin >> a[i];
f1[1] = max(a[1] , abs(a[1]));
f2[1] = min(a[1] , abs(a[1]));
if(a[1] >= 0)
{
w1[1] = 2;
w2[1] = 2;
}
else
{
w1[1] = 1;
w2[1] = 1;
}
for(int i = 2 ; i <= n ; i++)
{
f1[i] = max({f1[i - 1] + a[i],
abs(f1[i - 1] + a[i]),
f2[i - 1] + a[i],
abs(f2[i - 1] + a[i])});
if(f1[i] == f1[i - 1] + a[i])
w1[i] = (w1[i] + w1[i - 1]) % mod;
//cout << w1[i] << " " << w2[i] << endl;
if(f1[i] == abs(f1[i - 1] + a[i]))
w1[i] = (w1[i] + w1[i - 1]) % mod;
//cout << w1[i] << " " << w2[i] << endl;
if(f1[i - 1] != f2[i - 1])
{
if(f1[i] == f2[i - 1] + a[i])
w1[i] = (w1[i] + w2[i - 1]) % mod;
// cout << w1[i] << " " << w2[i] << endl;
if(f1[i] == abs(f2[i - 1] + a[i]))
w1[i] = (w1[i] + w2[i - 1]) % mod;
//cout << w1[i] << " " << w2[i] << endl;
}
f2[i] = min({f1[i - 1] + a[i],
abs(f1[i - 1] + a[i]),
f2[i - 1] + a[i],
abs(f2[i - 1] + a[i])});
if(f2[i] == f1[i - 1] + a[i])
w2[i] = (w2[i] + w1[i - 1]) % mod;
//cout << w1[i] << " " << w2[i] << endl;
if(f2[i] == abs(f1[i - 1] + a[i]))
w2[i] = (w2[i] + w1[i - 1]) % mod;
//cout << w2[i] << " " << w2[i] << endl;
if(f1[i - 1] != f2[i - 1])
{
if(f2[i] == f2[i - 1] + a[i])
w2[i] = (w2[i] + w2[i - 1]) % mod;
//cout << w1[i] << " " << w2[i] << endl;
if(f2[i] == abs(f2[i - 1] + a[i]))
w2[i] = (w2[i] + w2[i - 1]) % mod;
//cout << w1[i] << " " << w2[i] << endl;
}
}
cout << w1[n] << "\n";
for(int i = 1 ; i <= n ; i++)
w1[i] = w2[i] = 0;
}
}
Repost from Codeforces|Leetcode|Codechef free solutions
Proof of some previous year coding round helps.
We are also helping through remote access with a good application which is faster than other applications
Dm @Cpsoln to book your slots fast.
Repost from Codeforces|Leetcode|Codechef free solutions
Today's Microsoft slot done
Dm @Cpsoln for any coding round help
Repost from Codeforces|Leetcode|Codechef free solutions
Today's zscalar slot done🤩🤩
Dm @Cpsoln for coding round help
Repost from Codeforces|Leetcode|Codechef free solutions
Microsoft slot done 🥳
Dm @Cpsoln for help in coding rounds of any company
Repost from Codeforces|Leetcode|Codechef free solutions
Today's tesco slots done ✅✅✅
Dm @Cpsoln for coding round help
Repost from Codeforces|Leetcode|Codechef free solutions
Today's atlassian slot done🥳🥳🥳
Dm @Cpsoln for any coding round help
