Can someone tell how for S>=2N, Petya wins in the following problem with also the approach?

Problem Link:https://codeforces.com/problemset/problem/1355/D I am not able to get the editorial and the approach. Please Help. !!!!

# | User | Rating |
---|---|---|

1 | Benq | 3813 |

2 | tourist | 3768 |

3 | maroonrk | 3570 |

4 | Radewoosh | 3535 |

5 | fantasy | 3526 |

6 | jiangly | 3523 |

7 | Um_nik | 3522 |

8 | orzdevinwang | 3441 |

9 | cnnfls_csy | 3427 |

10 | zh0ukangyang | 3423 |

# | User | Contrib. |
---|---|---|

1 | awoo | 180 |

2 | -is-this-fft- | 178 |

3 | nor | 169 |

4 | Um_nik | 168 |

5 | SecondThread | 164 |

6 | maroonrk | 163 |

7 | adamant | 162 |

8 | kostka | 161 |

9 | YouKn0wWho | 158 |

10 | antontrygubO_o | 154 |

Can someone tell how for S>=2N, Petya wins in the following problem with also the approach?

Problem Link:https://codeforces.com/problemset/problem/1355/D I am not able to get the editorial and the approach. Please Help. !!!!

Problem Link :https://codeforces.com/contest/1607/problem/E

How is the below solution working ?? I found this in submission relatively easier than others . Can someone explain the intuition behind it? What I have understood is that we can move opposite to the direction s[i] in the string to get the required cooordinate. Can someone give a proper explanation for this and why are traversing string in the reverse direction?

#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
string s;
cin>>s;
int x=1,y=1;
for(int i=s.size()-1;i>=0;i--){
if(s[i]=='L'&&x<m)x++;
if(s[i]=='R'&&x>1)x--;
if(s[i]=='U'&&y<n)y++;
if(s[i]=='D'&&y>1)y--;
}
cout<<y<<" "<<x<<endl;
}
}

Can someone help me in fiding error in my code ?? It is failing on a test case but I am not able to figure it out . Problem Link : https://codeforces.com/contest/1562/problem/C

My logic :

**Case 1** — string contains all 1s then simply print starting and ending indexes of any two substrings of length **greater than n/2**. as they will be multiple of each other . like 11111111 >>> 1111 and 1111 their decimal values both will be multiple of each other .

**Case 2** — if the first zero is finding at length less than or = to n/2 then print the index of a substring starting from there till the end and other excluding that zero and till the end. Like 101111 >>> 01111 and 1111, their decimal values both will be multiple of each other .

**Case 3** — if the first zero is at length greater than n/2 then print the index of a substring starting from index 1 till it and the other starting from 1 to l-1. ****

**I think it is failing on Case 1** But not able to figure it out why and where Please Help!!!!!

void solve()
{
ll n;cin>>n;string s;cin>>s;
ll l=-1;
for(int i=0;i<n;i++)
{
if(s[i]=='0')
{
l = i+1;
break;
}
}
if(l==-1)
{
cout<<1<<" "<<n/2<<" "<<n/2+1<<" "<<n<<"\n";return ;
}
if(l<=n/2)
{
cout<<l<<" "<<n<<" "<<l+1<<" "<<n<<"\n"; return ;
}
else
{
cout<<1<<" "<<l<<" "<<1<<" "<<l-1<<"\n";return ;
}
}

Can someone help me in solving this game theory problem? I am not able to get the discussions /editorial , this problem is very tough . Please Help !!!!!!!!!!

Problem Link :

Problem Link :https://codeforces.com/contest/322/problem/B

The problem seems easy but there are two cases . I am not able to get case 2 which is explained in the editorial .

Case 1: First take out max of mixed flowers whcih we can make and then make individual flowers. long long mixed = min(min(r,g),b); r = r- mixed; g = g-mixed; b= b- mixed; long long ans1 = (mixed) +(r/3)+(g/3)+(b/3);

but I am not able to get case 2. maximum of two cases will be my answer.

Please Help !!!!!!!

How to solve this problem using Dp ??? I read the editorial and found that it has been solved using combinatorics but I saw others have solved it using Dp approach.

Problem Link -https://codeforces.com/contest/1288/problem/C

Please Help !!!! Thanks in advance

Problem Link :

https://codeforces.com/problemset/problem/1313/C1

Can someone help me in solving this greedy problem ????

I thought of 2 passes left and right and storing max and then changing the elements and then comparing the sum of both sides(left and right) but it is not working , Can someone suggest a good approach to solve this problem. There is no tutorial for this problem .

Thank You in advance.

Yesterday 's contest had some very good problems , unfortunately, it became unrated.

Problem Link : https://codeforces.com/contest/1573/problem/C

The problem is based on standard topological sort Prerequisite problem .

If the cycle was found in the graph I printed -1 as the answer.

else I found the topical sort of all the chapters , using cycle detection + DFS + queue.

After finding the topological ordering of chapters (stored in a queue a ->b->c->d.... )how do I count the number of times I will have to read the book/number of passes required ???

Please help !!!

Can someone help me in solving this problem?? The problem editorial is tough to understand. It can be solved using hashmap +prefix sum but I am not able to the get the pattern/observation.

C. Good Subarrays Educational Codeforces Round 93 Problem Link :https://codeforces.com/problemset/problem/1398/C

Can someone help me in solving this greedy problem ?? https://codeforces.com/problemset/problem/276/C I am not able to understand the editorial .

Thanks in advance !!!! Happy coding !!!

How to solve this problem using bitmask or bit manuplation ??

**Problem Link** :https://codeforces.com/problemset/problem/1097/B **Editorial Link** :https://codeforces.com/blog/entry/64310

I am not able to understand the editorial which says that clockwise rotation will be done if ith bit is set to 0 and vive versa ?? Can someone explain in detail ?

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/02/2023 11:09:50 (k2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|