Блог пользователя FetFot

Автор FetFot, 11 месяцев назад, По-английски

Thank you for your participation! We hope you enjoyed the problems! We would love to hear your feedback! Please share your thoughts in the comments.


How did you find the contest?
Which problem was your favorite?
Which problem did you find the least enjoyable?


2109A - It's Time To Duel

Idea by MOUFLESS, prepared by MOUFLESS.

Hints
Solution
Code
Rate the Problem

2109B - Slice to Survive

Idea by MOUFLESS, prepared by MOUFLESS and FetFot.

Hints
Solution
Code
Rate the Problem

2109C1 - Hacking Numbers (Easy Version)

Idea by MOUFLESS, prepared by MOUFLESS and FetFot.

Hints
Solution
Code
Rate the Problem

2109C2 - Hacking Numbers (Medium Version)

Idea by MOUFLESS, prepared by MOUFLESS and FetFot.

Hints
Solution
Code
Rate the Problem

2109C3 - Hacking Numbers (Hard Version)

Idea by MOUFLESS, prepared by MOUFLESS and FetFot.

Hints
Solution
Code
Rate the Problem
Fun facts

2109D - D/D/D

Idea by MOUFLESS, prepared by MOUFLESS and FetFot.

Hints
Solution
Code
Rate the Problem

2109E - Binary String Wowee

Idea by Intellegent, prepared by Intellegent.

Hints
Solution
Code
Rate the Problem

2109F - Penguin Steps

Idea by MOUFLESS, prepared by MOUFLESS.

Hints
Solution
Code
Rate the Problem
The Making of F
Разбор задач Codeforces Round 1025 (Div. 2)
  • Проголосовать: нравится
  • +251
  • Проголосовать: не нравится

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Intuition behind C2?

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +178 Проголосовать: не нравится

i realized even LGMs took nearly 15-20 minutes on C3 showing its not a knowledge check but rather an insanely high quality problem

loved the contest

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

C is really amazing! Only solved c1 c2 :(

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Blazingly fast editorial

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится -17 Проголосовать: не нравится

F is a really good question well structured, and nicely written. My logic regarding dinic was wrong ig but the solution and hints make much more sense than whatever I was trying anyways

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +37 Проголосовать: не нравится

The super path in problem F seems to be the same as the left-hand rule in solving a maze, and that is how I implemented this problem.

I cannot find a proof that is intuitivem but it is probably right.

My implementation:

Spoiler
»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится -28 Проголосовать: не нравится

(c1) I was thinking about making it one. I was thinking about repetitive summation. But I couldn't put them together. And this was all in the very beginning. I probably would have easily solved C2 & C3 and then jump by like 1000 rating. (Sigh).

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

Loved C. I will use this as a riddle for non-cpers. Thank you for the lightning fast editorial as well

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +3 Проголосовать: не нравится

.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

One of the best contests && editorials so far!

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится -6 Проголосовать: не нравится

In problem C1

for the case "5 1234" By my logic, I'm getting correct answer, but getting wrong verdict could someone please help

my submission 320120751 `

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

not being able to find my error in c1 sample test 2 here is my code 320132118

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +34 Проголосовать: не нравится

Thank you for the great round and fast editorial.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can someone explain why this does not work 320080436

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

why does this solution for C1 fail?

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain to me why, in problem B it is necessary to check all four possible initial cuts, instead of choosing the one that minimizes n'*m'? Thank you in advance :D

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

C was an amazing problem and I thoroughly enjoyed D as well. Best Div-2 in a while imo.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

https://mirror.codeforces.com/contest/2109/submission/320143895 https://mirror.codeforces.com/contest/2109/submission/320143592 Why using vector is giving runtime error this is the only difference between these submissions can someone explain :)

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

To solve both C1 and C2, I focused on C2 first, knowing its logic would cover C1 as well. The key insight came from observing that the sum of digits of a number is equivalent to the number modulo 9, which led me to search for a uniform target, and 9 fit perfectly, as any multiple of 9 eventually reduces to 9 through repeated digit sums. I tested several approaches:

Case 1: Take the sum of digits first, then multiply → ❌ Fails for large numbers like 999999999 (e.g., sum = 81 → 729, sum again = 18 → not reliable). Case 2: Take the sum of digits twice, then multiply → ❌ Still unreliable, doesn’t guarantee reduction to 9. Case 3: Multiply first, then take the sum of digits twice → ✅ Works for all values, including edge cases like 999999999, always reduces to 9.

Once we reach 9, we can add (n-9) to get the desired n, making all inputs consistent and efficient. I hope this provides some help on how we can approach the answer...

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +50 Проголосовать: не нравится

C3 is an extremely amazing problem.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In Question D,

I found the mininum odd distance and even distance.

Then I am preprocessing array to find the maximum even distance and odd distance we can go from node 1.

then for every node i am checking if minimum odd distance or even distance is within reachable range.

But the logic is failing in 6test case, can someone please help in finding the issue in below logic

bool isPresent(int e,int o,int even, int odd){ if((e<=even && e>0)|| (o<=odd && o>0))return true; return false; }

 int oddsum=0;
    int evensum=0;
     sort(a.begin(),a.end());
    vector<int>odd;

    for(int i=l-1;i>=0;i--){
        if(a[i]%2==0){
            evensum+=a[i];
        }
        else{
            odd.push_back(a[i]);
        }
    }
    for(int i=0;i<odd.size()/2*2;i++){
        evensum+=odd[i];
    }
    if(odd.size()%2==1){
        oddsum=evensum+odd[odd.size()-1];
    }
    else{
        if(odd.size()>=2){
            oddsum=evensum-odd[odd.size()-1];
        }
    }

   
    string str="1";
    for(int i=2;i<=n;i++){
        if(isPresent(dist[i][0],dist[i][1],evensum,oddsum)){
            str+='1';
        }
        else
            str+='0';
    }

    cout << str << endl;
»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I thought question B could be simulated:the first preson choose the max area of four directions and cut, then the second person choose the mid point of the grid, but it is wrong, i want to know why, who can explain this question :D

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

make_pair(a, m), make_pair(n — a + 1, m), make_pair(n, b), make_pair(n, m — b + 1)});

can anyone explain why need to do this for Question B

If it is just for symmetry then output should have been same for below code also ?

#include<bits/stdc++.h>
using namespace std;
int cal(int a){
    int z=0;
    while(a>1){
        a=(a+1)/2;
        z++;
        
    }
    return z;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,m,a,b;
        cin>>n>>m>>a>>b;

        cout<<min(1+cal(a)+cal(m),1+cal(b)+cal(n))<<endl;
    }
}


»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem D is so similar to this problem.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What was div useful for in problem C? Is there any solution using it?

»
11 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

This submission fails on Test 6 can anyone help me with what is wrong? problem D

320150215

edit: i changed the max distance of a node from 1 to 1e18 from the previous 1e9 and it works

forgot to see that max(a[i])*l is atmost 2e9

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can someone explain why this does not work in C1:

"add -5"
"add -3"
"add -2"
"add -1"

it should make all numbers 1 <= x <= 9 to 1, right? Or am I missing something?

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I really enjoyed every problems and one of the best contest I ever participated

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

my thinking was correct for D but couldnt implmenet it ;/

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone please explain the solution for B. i am unable to understand through editorial.

  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    okay so after your first cut, the monster is always going to move to the middle as much as it can to slow you down. so the best thing you can do is just keep cutting things in half.

    so you just try cutting up to where the monster is in all 4 directions. then for each cut, look at what you have left and figure out how many times you'll have to halve the rows and the columns (ceiling half because hes going to move to the side worst for you) until you have 1x1 and the minimum of the 4 is your answer

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

will someone please explain the jury thing to me please, I'm new. Much Appreciated :)

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I'm so mad i got C1 correct from my first try but missed the last cin after the "!" aghh

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

hello this is my first comment and i need some help on why my approach for prob B is wrong here.


while(t-->0){

        int n = xc.nextInt();
        int m = xc.nextInt();
        int a = xc.nextInt();
        int b = xc.nextInt();

        if(n-a+1 < a) a = n+1-a;
        if(m-b+1 < b) b = m+1-b;

        long ans = 0;

        if(n>m){
            n=a;

            ans++;
        }

        else{
            m=b;
            ans++;
        }

        ans += (int)Math.ceil(Math.log(n)/Math.log(2));
        ans += (int)Math.ceil(Math.log(m)/Math.log(2));

        xc.println(ans);

```````````````````

my intuition is if the rows are larger than columns and regardless of where the monster is at first. we should always divide rows because else then in the next case we gotta divide them anyway.

my code is failing on the last case of test case 1. where it gives answer 11 instead of the given 10

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For question B, why is it wrong to delete the largest block in all four directions every time? Is there a counterexample ? my code

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Loved problem D.

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

What if we slightly change the problem statement in 2109B - Slice to Survive:

In each turn:

  • Mouf first cuts the grid along a row or column line into two parts, discarding the part without Fouad's monster. The grid must have at least two cells; otherwise, the game has already ended.

  • Then, in the same turn, Fouad moves his monster to any adjacent cell (up/down/left/right) within the remaining grid.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +23 Проголосовать: не нравится

In C3 solution, this line

$$$S(1 \cdot y) \le 80 \lt 81 = S(999\,999\,999\cdot y)$$$

but this condition only holds for $$$y\in[1,10^9], y\neq 10^9-1$$$, right?

how about mul y for $$$y\in[10^9+1,10^{18}]$$$?

»
11 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

In problem C1 I think that in case x=19 after 2 times use "digit" will make it equal to 0 so we need 1 "add 0" to find it so we need 8 questions or digit only return non-zero? Am I missing something ?(sorry for my bad english)

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

in D-D-D it is written that there is no cycle in the graph but in the pretest 1 the subtest 2 there is cycle in it 5 5 1 5 1 2 2 3 3 4 4 5 3 5 in this 3 is connected with 5 and 4 and 4 and 5 are connected. please clarify if i did it incorrectly

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone please tell me why its showing wrong output for problem B? Even though i checked multiple times ~~~~~~~~~~~~~~~~~~~~~~~~~ //this is code

include <bits/stdc++.h>

using namespace std;

void counti(int n, int m, int a, int b, int* count) { if (n == 1 && m == 1) return;

int left = (b - 1) * n;
int right = (m - b) * n;
int top = (a - 1) * m;
int bottom = (n - a) * m;


int maxi = max({left, right, top, bottom});

if (maxi == left) {

    m = m - (b - 1); 
    b = 1;          
} else if (maxi == right) {

    m = b;         

} else if (maxi == top) {

    n = n - (a - 1);
    a = 1;           
} else {

    n = a;          

}


a = ceil(n / 2.0);
b = ceil(m / 2.0);

(*count)++;
counti(n, m, a, b, count);

}

int main() {

int t;
cin >> t;

vector<int> ans;

for (int i = 0; i < t; i++) {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    int count = 0;
    counti(n, m, a, b, &count);
    ans.push_back(count);
}

for (auto i : ans) {
    cout << i << endl;
}

return 0;

} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone please tell me why this approach 320081025 for 2109B - Slice to Survive is wrong. My idea was the person cuts such a way that the number of squares would be minimum and other one always tries to go to the center of the remaining part

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

D<<<C1 :<

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

10/10 contest

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone help me find whats wrong in my code for B

// this is my code ~~~~~ int main() {

ll T;
cin >> T;

while (T--) {

ll n,m,a,b;cin>>n>>m>>a>>b;
ll c=0;
while(!(n==1 && m==1)){

       if((min(a,n-a+1)*m)<(min(b,m-b+1)*n)) n=min(a,n-a+1);
        else m=min(b,m-b+1);
        a=(n+1)/2;b=(m+1)/2;
        c++;

}
cout<<c<<endl;


}

return 0;

} ~~~~~

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can someone point out where my submission for B is giving WA. 320076938

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone tell the mistake in my code? Unable to understand where I have gone wrong. 320113345

:-(

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится -14 Проголосовать: не нравится

For problem B, the editorial suggests a $$$O(log(n) + log(m))$$$ solution by dividing $$$n$$$ and $$$m$$$ by 2 until they are 1. Why not just compute the $$$\log_2(n)$$$ and $$$\log_2(m)$$$ which would result in a $$$O(1)$$$ solution. See 320205143 for implementation.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone help me with Problem D? Why am I getting TLE in test case #7 while my solution is the same. #320193695

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain me why in B task moving monster into center is not best strategy? Or maybe say why this solution gets wa2 at test №1516 (!!!)

Spoiler
  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    It is not obvious why greedily selecting the rectangle with the smallest area is the optimal strategy.

    • »
      »
      »
      11 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      I select center because then the max chunk that first player could cut is smaller than any max chunk for any other positions of monster. And then first player chooses cut for the min possible chunk, so monster has less space to be, so first player will faster catch him to 1 cell (that are just my thoughts, i haven't proofs). If it's good solution — idk why that crashes, otherwise, if it's bad — idk why this solved 1515 tests...

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

/*in Q B i am doing a cut to the largest part then fit monster in the exact mid of it and keep doing untill n==m==1

can't understand why getting wrong on given test case 22 99 20 70 getting 11 should get 10, can anyone explain */ ~~~~~

// this is the code

void doit(int n, int m, int a, int b, int &x) { if (n <= 1 && m <= 1) return;

long long top = a - 1;
long long bottom = n - a;
long long left = b - 1;
long long right = m - b;

long long best = max({top, bottom, left, right});

int n1 = n, m1 = m, a1 = a, b1 = b;

if (best == bottom) {
    n1 = top + 1;
    a1 = (n1 + 1) / 2;
    b1=(m+1)/2;
} else if (best == top) {
    n1 = bottom + 1;
    a1 = (n1 + 1) / 2;
    b1=(m+1)/2;
} else if (best == right) {
    m1 = left + 1;
    b1 = (m1 + 1) / 2;
    a1=(n+1)/2;
} else {
    m1 = right + 1;
    b1 = (m1 + 1) / 2;
    a1=(n+1)/2;
}

x++;
doit(n1, m1, a1, b1, x);

}

void solve() { int n, m, a, b; cin >> n >> m >> a >> b;

int x = 0;
doit(n, m, a, b, x);

cout << x << endl;

} ~~~~~

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Good Div2 thx for the contest

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Can somebody explain why vector<array<int, 2>> dist(n, {1e9, 1e9}); does not work but 2e9+1 works in problem D? Submission

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

man!what can i say!?I can simply and straightforwardly state that we didn't reach that conclusion about the number 9 in high school.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In task "2109A — It's Time To Duel" There must be at least one player with 0.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone tell me what am I doing wrong with problem B?

320251774

It gives WA at 1516th test case at test case 2.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone tell why the largest area elimination approach does not work in problem B??

  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Because it assumes the monster won’t move after the cut. But in this game, Fouad can move to the worst-case position for Mouf every time. So removing the largest area doesn’t guarantee the fewest moves, as Fouad can reposition to force more turns. Instead, we must consider how many times we need to halve both row and column ranges, assuming Fouad always moves optimally to delay the game.

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I have been thinking about the solution with flow for the last problem. I basically got the the point where I need to find the minumum cut between bottom left and destination while keeping the top left on the destination side. Is there some min cut algo that allows you to force a node to be on one side of the cut? If not, does anyone know the intended solution?

  • »
    »
    11 месяцев назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится 0 Проголосовать: не нравится

    This is the fastest flow solution we came up with while testing; it took about $$$15$$$ seconds to pass tests. However, when the intended solution was the min-cut, the constraints differed ($$$n^2 \le 400$$$).

    You can see the min-cut solution here: 320339656.

  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    You can add edges with INF weight S -> X to force node X to be in S side, more generally, you can add that type of edge to force a set of nodes to be always in exactly one of the 2 sides. I did come up with the dijkstra solution so idk the flow implementation detalis. See this submission on other problem that uses that idea

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can anybody tell why my code is failing in Problem B in test case 2 in which 1516th numbers differ , my submission code — https://mirror.codeforces.com/contest/2109/my

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My friend wrote some cheaters' name to MOUFLESS. Remove them from contest. Some copy from AI, some others use ChunkCode01 or a telegram channel called Contest Solvers. I looked all the submissions of the people who are newbie and are in the top 200. Most of the codes were identicial and most of them wrote ChunkCode01 as coment in their codes so, i researched and found that it is a Youtube channel giving the codes of the all problems' solution.

»
11 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

In the proof of C3 what happens if $$$(x - 1) \gt 10^d - 1$$$ (i.e. $$$(10^d - 1) - (x-1)$$$ is negative)

  • »
    »
    11 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    The proof breaks. But if $$$x - 1 \gt 10^d - 1 \dot\implies x \gt 10^d$$$, then $$$x \not\in [1, 10^d]$$$, i.e. the assumption of the proof is not satisfied and it doesn't matter (since the proof is a statement of the form $$$x \in [1, 10^d] \implies ...$$$).

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hi guys, i have a question to Problem a. We say that if The reported values were 101 for example, then it is valid and no one lied. But I think in this case it is possible that everyone lied since 010 is a possible outcome. And then everyone could lie to make it 101. Am I thinking right or am I missing something? Thanks in advance

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone can explain test case 3 of B? why 4

i think it is 3. f(2,2) (n,m)=(3,3) -> the first turn: (n, m) = (3,2) f (1,1) -> second turn: (n,m) = (3,1) f(1,1) -> the third (n,m) = (1,1) f(1,1). the game end

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hi, I am having trouble understanding the E. I fail to understand the DP's transitions. and the intuition behind it. Can someone help me unlock this huge mindgap !? Thanks

»
11 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Test case for 1516 for B Slice to Survive: would be something like this: 1

7 17 3 8

The answer should be 7, but the greedy algorithm if done to maximize the size of the part to be removed would give 8 as the answer for this. Essentially for the first step you should do a vertical cut instead of horizontal one. I think we can't choose a greedy option for step 1, cause if you choose the logic that do a cut that reduces the maximum side (rows or cols) first which would pass this case, but fail in :

1

22 99 20 70

So essentially we have only the choice of the first move, to decide which edge does F reaches nearer too, other than that it's gonna be half of that edge and a fixed number of moves. So for the first choice we need to check all possible ways only.

»
11 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can't we just use recursion for E (basically brute force)? let the initial state be f(s,k) First, we find all the indices i where s[i] = '0', then for each i, we find the string that comes by flipping the first i characters of the string (call this t) we then sum f(t,k-1) for all possible strings t. I calculated the time complexity to be O(n2k), which I don't think should give any problems, but I don't think the solution will be this straightforward. Can anyone tell me if I'm missing something? Edit: Ok NVM my brain wasnt working when I first wrote this

»
11 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

2109A — It's Time To Duel The code gives correct answers for all the sample test cases, but it is not getting accepted upon submission. Could someone please help me identify the issue? I'm new here nice to meet you all!

~~~~~~~~~~~~~~~~

This is code

t= int (input())

for _ in range(t): n = int(input()) a = list(map(int, input().split()))

if (n % 2 == 0):
  if (sum(a)% 2 == 0):
    print("yes")
  else:
    print("No")

else:
  if (sum(a)%2 != 0):
    print("No")
  else:
    print("Yes")

~~~~~~~~~~~~~~~~~~~~~

»
11 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

a

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone explain why this does not work https://mirror.codeforces.com/contest/2109/submission/324617912

it fails particularly for the case

538585931 350004549 292308221 202610425

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone tell what's wrong in this code, why is it giving runtime error for https://mirror.codeforces.com/problemset/problem/2109/C1 this problem

I am 100% sure that my approach is correct. Please look in solve() function

this is my submission https://mirror.codeforces.com/contest/2109/submission/325876581

»
9 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

the solution of problem b was unclear

»
6 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
typedef long long ll;
void solve(){
	int n,m,a,b; cin >> n >> m >> a >> b;
	for(int i =1;i <= 256;i++){
		if(n == 1 && m == 1){
			cout << i-1 << endl;
			return;
		}
		if(max(a-1,n-a) >= max(b-1,m-b)){
			n = n - max(a-1,n-a);
			a = (n+1)/2;
			b = (m+1)/2;
		}
		else {
			m = m - max(b-1,m-b);
			b = (m+1)/2;
			a = (n+1)/2;
		}
	}
}

int main(){
	ll tt = 1; cin >> tt;
	while(tt--){
		 solve();
	}
	return 0;
}

Can anyone point out why is it giving me wrong answer for test case : 22 99 20 70

»
6 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Anyone pls help? C1

Why i am getting WRONG ANS although my soln is same as editorial? 344622024

»
5 месяцев назад, скрыть # |
Rev. 5  
Проголосовать: нравится 0 Проголосовать: не нравится

https://mirror.codeforces.com/contest/2109/submission/351443596

hi FetFot. My AC solution for D has a silly mistake because I found the overall minimum instead of the minimum odd number. However, it still gets AC. Was this accepted due to weak test cases?

»
4 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

in B I found the region which needs to be removed that eliminates the max rows and columns and then updated m and n accordingly and then did the same way as in editorial to find the remaining no of steps required but getting stuck on tc2. It would be great if someone could help. 353232624