C. Manhattan Permutations Codeforces Round 953 (Div. 2)

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024

ความคิดเห็น • 10

  • @-ArnobBiswas
    @-ArnobBiswas 3 หลายเดือนก่อน

    Consider the case n=5 and k=12, so in the first iteration we are looking in the set for the value 6+1=7, which should return st.end() and dereferencing it should give a garbage value unless we handle this case. I don't understand how did it get accepted.

  • @mennaselim409
    @mennaselim409 4 หลายเดือนก่อน +1

    Thanks for this explanation. Do you have any recommendations for improving observation skills?

    • @jeevanalexen
      @jeevanalexen  4 หลายเดือนก่อน

      Not really, I have explained how I observed the observations in the problem, it was either by trying to find a pattern or trying to think in terms of how I have solved similar problems previously.

    • @jeevanalexen
      @jeevanalexen  4 หลายเดือนก่อน

      We're you able to understand my explanation properly?

    • @mennaselim409
      @mennaselim409 4 หลายเดือนก่อน

      @@jeevanalexen yup I was able to understand your explanation, thanks a lot, but I am not able to make good observation and notice the pattern. is it improved by practice or is there technique to do this?

    • @jeevanalexen
      @jeevanalexen  4 หลายเดือนก่อน +1

      ​@@mennaselim409it can be improved only by practise.

  • @deboshrutimukhopadhyay7925
    @deboshrutimukhopadhyay7925 4 หลายเดือนก่อน

    could you explain why this code is not getting accepted though I went with a similar approach
    #include
    using namespace std;
    #define ll long long
    int main() {
    int t;
    cin >> t;
    while (t--) {
    long long n, k;
    cin >> n >> k;

    // Check if k is odd
    if (k % 2 != 0) {
    cout

  • @vedanta-xw3se
    @vedanta-xw3se 4 หลายเดือนก่อน

    why are u using remain + i + 1 why not just remain

    • @jeevanalexen
      @jeevanalexen  4 หลายเดือนก่อน

      Because we are doing val - (i+1) below, there we subtract i+1 from val. So to negate that, we are taking remain + i + 1, so that the subtraction below wont affect it.

    • @jeevanalexen
      @jeevanalexen  4 หลายเดือนก่อน

      Please let me know if you need further explanation