problem E can be simplified just keep a variable cnt which will be storing active flips how ? just increase cnt when you insert into set and decrease it when you reach that index if cnt is odd , it means at current index flip is going to happen if cnt is even it means the there is no need to flip code : void solve () { int n ; cin >> n ; string s ; cin >> s ; int ans = 0 ; for (int i = n ; i >= 1 ; i--) { string temp = s ; set st ; int cnt = 0 ; for (int j = 0 ; j < n ; j++) { if (cnt & 1) { if (temp[j] == '0') temp[j] = '1' ; else temp[j] = '0' ; } char curr = temp[j] ; if (curr == '0' && j + i - 1 < n) { cnt++ ; temp[j] = '1' ; st.insert(j+i-1) ; } if (st.find(j) != st.end()) cnt-- ; } bool flag = true ; fl(j,n) { if (temp[j] == '0') flag = false ; } if (flag) { ans = i ; break ; } } cout
@@AbhinavAwasthi #include using namespace std; void solve() { int n, k; cin >> n >> k; deque q; for (int i = 0; i < n; i++) { int a; cin >> a; q.push_back(a); } int f = 0; while (k > 0&&!q.empty()) { if (f == 0) { int a = q.front(); q.pop_front(); a--; if (a > 0) q.push_front(a); f = 1; k--; } else { int a = q.back(); q.pop_back(); a--; if (a > 0) q.push_back(a); f = 0; k--; } } cout t; while (t--) { solve(); } return 0; }
I don't know sir why i can't access the website.Its reload and show website not found. I tried with my laptop and phone, and also with some friends but they are also facing the same things
@@AbhinavAwasthi Sir while solving cp sheet i found that when i click on next page of question and click the question then it will back to the previous page
he used to do that ...but nowadays i think he is getting busy...he making the logical part of problerm little less, the way he explains is really amazing ...
For the problem c why is this code giving wa? #include using namespace std; int main(){ int t; cin>>t; for(int i=0;i>n>>k; long long a[n]; for(int j=0;j>a[j]; } int start=0,end=n-1; while(start
Because it was alternate but in your implementation, you first remove first index then last but it should be that first index -1 then last-1 then first -2... Urs is doing first -first, last -last....
@@YangKai-yj9bk yeah, I am decrementing the first index by 1 and then the last index by 1 until the element at the particular index disappears. It is being decremented like mentioned in the question.
@@AbhinavAwasthi yeah The thing he is lacking mainly is that whenever start gets 0 then he just goes to next start instead of decreasing the next start by 1.similar for the end
Visit coding75.com
sir website not working!!
problem E can be simplified
just keep a variable cnt which will be storing active flips
how ?
just increase cnt when you insert into set and decrease it when you reach that index
if cnt is odd , it means at current index flip is going to happen
if cnt is even it means the there is no need to flip
code :
void
solve ()
{
int n ;
cin >> n ;
string s ;
cin >> s ;
int ans = 0 ;
for (int i = n ; i >= 1 ; i--)
{
string temp = s ;
set st ;
int cnt = 0 ;
for (int j = 0 ; j < n ; j++)
{
if (cnt & 1)
{
if (temp[j] == '0') temp[j] = '1' ;
else temp[j] = '0' ;
}
char curr = temp[j] ;
if (curr == '0' && j + i - 1 < n)
{
cnt++ ;
temp[j] = '1' ;
st.insert(j+i-1) ;
}
if (st.find(j) != st.end()) cnt-- ;
}
bool flag = true ;
fl(j,n)
{
if (temp[j] == '0') flag = false ;
}
if (flag)
{
ans = i ;
break ;
}
}
cout
IN PROBLEM C, WHY HOW YOU GET THE IDEA OF SUM>K,THEN ALL THE SHIPS WILL BE DESTROYED AND IF SUM
if number of attacks is greater than the total health of all ships then obviously all ships will be destroyed regardless of the order
N-1 because we know lb1 and lb2 are at same ship, means all other ships are destroyed, we have to just check for that one ship
what might be the rating of the Problems, c d e in your opinion?
Around specialist to expert
Is it okay to say that we dont need m1 map for D question because it is not used in any conditional statements or in any increment of ans?
Umm yes
How sir you think implementation of d problem for me its very difficult
Keep trying, you will also improve your problem solving skills
can anyone tell me why when i used dequeue in C ques it gave me TLE?
k upto 1e15 that's why
can you send your code
@@AbhinavAwasthi #include
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
deque q;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
q.push_back(a);
}
int f = 0;
while (k > 0&&!q.empty()) {
if (f == 0) {
int a = q.front();
q.pop_front();
a--;
if (a > 0)
q.push_front(a);
f = 1;
k--;
} else {
int a = q.back();
q.pop_back();
a--;
if (a > 0)
q.push_back(a);
f = 0;
k--;
}
}
cout t;
while (t--) {
solve();
}
return 0;
}
Amazing channel with amazing tutor
Glad you think so!
Great explanation 🎉
Thanks
I could solve first 2 ques
A and B in 1 hour, what will my rating be?
Can't say, may be pupil or 1100
Can say, can be pupil or 1100
.
@@AbhinavAwasthi Thanks. It was my second contest, my rating increased from 400 to 600 lol
in any division if you able to solve A and B in 1 hr...then your rating would be around 1000-1100 not greater than 1100 at any cost bro
sir why CP Sheet website not working??
it's working from my side, what's the problem you are facing? please fill the feedback form in case of any problem
I don't know sir why i can't access the website.Its reload and show website not found. I tried with my laptop and phone, and also with some friends but they are also facing the same things
@@karnelchakma3498 can you send screenshot on telegram? Also the site url you are using
@@karnelchakma3498 WhatsApp me here: 9956217210
@@AbhinavAwasthi sir i checked with VPN, it's working now. Sir I am from Bangladesh 🇧🇩
bhai kya kar rha hai again problem e kuch samajh nhi aaya
please explain not upload video for views
so sorry, may be i was little fast in this video, will improve this for sure
Great explanation!
Thanks
True legend❤❤
Thanks ❤
@@AbhinavAwasthi Apne code chef ke solutions nhi banaye?
Was travelling last week
Sir in your website there is an issue kindly fix it
Please tell
@@AbhinavAwasthi Sir while solving cp sheet i found that when i click on next page of question and click the question then it will back to the previous page
@@adarshsinghparihar7321 hey, we are fixing this issue, will be done by today
Helpful ❤
Thanks
sir please improve the flow of explaining the logic and also do some dry run
Sure, thanks for suggesting, will work on it
@@AbhinavAwasthipls do not directly jump on the implementation, first explain the logic, so that we can try implementing on our own.
he used to do that ...but nowadays i think he is getting busy...he making the logical part of problerm little less, the way he explains is really amazing ...
helpful
Glad to hear that
i have just answered the A problem and ans got accepted , mujhe kuch raating milega kya?
No, only for during contest
@@AbhinavAwasthi yes i answered during the contest
❤❤❤❤
your volume is low
will check it
worst explaination ever seen. dont explain code bro, just explain logic.
Getting very bad reviews for this video 🥲 sorry
@@AbhinavAwasthi its okay, improve next time
For the problem c why is this code giving wa?
#include
using namespace std;
int main(){
int t;
cin>>t;
for(int i=0;i>n>>k;
long long a[n];
for(int j=0;j>a[j];
}
int start=0,end=n-1;
while(start
Because it was alternate but in your implementation, you first remove first index then last but it should be that first index -1 then last-1 then first -2... Urs is doing first -first, last -last....
@@YangKai-yj9bk yeah, I am decrementing the first index by 1 and then the last index by 1 until the element at the particular index disappears. It is being decremented like mentioned in the question.
Try to have a dry run
Try to have a dry run
@@AbhinavAwasthi yeah The thing he is lacking mainly is that whenever start gets 0 then he just goes to next start instead of decreasing the next start by 1.similar for the end