Please read the new rule regarding the restriction on the use of AI tools. ×

yash_daga's blog

By yash_daga, history, 28 hours ago, In English

We invite you to participate in CodeChef’s Starters 155, this Wednesday, 9th October, rated upto 5 stars (i.e. for users with rating < 2200)

Time: 8:00 PM — 10:00 PM IST

Joining us on the problem setting panel are:

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here. Hope to see you participating.

Good Luck!

  • Vote: I like it
  • +53
  • Vote: I do not like it

»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

The contest starts in around ~15 minutes.

»
35 minutes ago, # |
  Vote: I like it +1 Vote: I do not like it

What wrong with this Replace With First's logic ?

#include <bits/stdc++.h>
using namespace std;

int main() {
    int tt;
    cin >> tt;
    
    while (tt--) {
        int n, m;
        cin >> n >> m;
        
        string s, t;
        cin >> s >> t;
        
        if (s == t) {
            cout << 0 << endl;
            continue;
        } else if (s[0] != t[0]) {
            cout << -1 << endl;
            continue;
        } else {
            int flag = 0;
            for (int i = 0; i < min(n, m); i++) {
                if (s[i] != t[i]) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 0) {
                cout << 1 << endl;
            } else {
                cout << 2 << endl;
            }
        }
    }
    return 0;
}
  • »
    »
    30 minutes ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    lets say s== lion, t = lioeeeeeeen we can make do o-> oeeeeeee in 1 operation but your code will give 2

  • »
    »
    29 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    i wrote the same logic but it wasn't working, I wanna know why so bad

    • »
      »
      »
      28 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You can remove an internal substring from the larger string to make it equal to the smaller string, that would take just one move too.

»
13 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

why is in gcd(hard) question, printing matrix with all number as 2 is wrong?

  • »
    »
    8 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    maybe because any row and column gcd will be 2 ??

  • »
    »
    4 minutes ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Gcd should be 1 and not 2 in each row and column; printing 1 would make gcd 2; you should atleast look the given test cases

»
5 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

I have a question for those who solved problem Div1C (Div2D) Prefix Suffix Min Max ,

How did u figured out the solution ? did u solve almost similar problem before or solved it just now ?