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

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

I would like you to read the full story and give me some feedback on it, Thank You.

Today I was solving this amazing 715A - Плюс и квадратный корень problem. After finding the idea and implementing it in C++, I submitted it in C++17 and later in C++20.

But I was getting the wrong answers in the main test 5. At first, I thought my idea was wrong and I tried to prove my idea. Thinking about the problem the whole day I got nothing wrong with my approach and implementation.

By not finding any other way I opened my submission and then I saw the reasons for the wrong answer 198441320. But in theory and my implementation method, there could not have errors such as this.

After that, I got experimental and tested the code, and changed certain bits. But whatever I did it didn't change the verdict.

The main part of my code was:

ll lcm(ll a, ll b){
    ll LCM = (a * b);
    return LCM;
}
void solve(){
    
    ll n;
    scl(n); // scan in long long

    ll LCM = 2;

    for(int i = 1; i <= n; i++){
        ll templcm = lcm(i, i + 1);
        ll res = (templcm - LCM) / i + (templcm / i) * (templcm - 1);      
        cout << res << endl;
        LCM = templcm;
    }
    return;
}

But after that, I submitted the same code with the change of variable type of i (loop Variable) that got AC 198513530.

// Previous codes are unchanged

for(ll i = 1; i <= n; i++){
    ll templcm = lcm(i, i + 1);
    ll res = (templcm - LCM) / i + (templcm / i) * (templcm - 1);      
    cout << res << endl;
    LCM = templcm;
}    

Here I should not have got this verdict because in whatever the type of i (loop Variable) be, it should be converted to long long.

Now I was having fun, in another version: I have declared another variable j, and did this and that also got an AC:

 for(int i = 1; i <= n; i++){
        ll templcm = lcm(i, (i + 1) ), templcm2 = lcm(j, j + 1);
        templcm = templcm2;
        ll res = (templcm - LCM) / i + (templcm / i) * (templcm - 1);
        if(templcm != templcm2){
            cout << templcm << " " << templcm2 << endl;
        }
        cout << res << endl;
        LCM = templcm;
        j++;
    }

Finally, I submitted my first submission (Where i in int type) 198505674 in C++14 and with the help of magic it got AC That same code that got WA in C++ 17 and C++20 got AC in C++14.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

Автор PARTHO_DAS, 3 года назад, По-английски

Hi, I really wanna thank Codeforces in short.

I live in Bangladesh. In my county, COVID-19 hit around Jan-2020. Our college and every educational institution were closed for around 1.5 years. My life felt purposeless and dull.I had nothing to do. Time become frozen and felt like a day doesn't pass.

The entertainment become predictable, Nothing new was released. At that time I just saw one site become a part of my life. Like my morning coffee.

That site was not slowing down its activities and I saw it becoming more popular. The site I am talking about you already guessed it, Yes Codeforces.

I have invested time to solve problems and learn new things from this site. When I think about this site, I think how much effort is given to this site by some awesome volunteers.

I just become amazed and the best part of this site is, it is Free. I am especially thankful to MikeMirzayanov for this platform God Bless You.

Thank you Codeforces Team. I am grateful to you and wish you all "Happy New Year" in Advance.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +354
  • Проголосовать: не нравится

Автор PARTHO_DAS, 3 года назад, По-английски

Hi there,

After getting Accepted to Timofey and a tree problem with DSU. I found that my solution was wrong.

My approach: In DSU I kept a vertex X in Group D if vertex X has the same color as parents of group D and there is an edge between X and some vertex of group D.

Now for calculating the result. I was iterating over every vertex. In every iteration, I visited over his adjacent vertices and kept count of their group size. After vising, if the count is equal to n — 1 then I say this is my answer and return.

If I could not get any answer then I say there is no answer.

The Main Problem: In the iteration of every vertex. I count for the same group many times for different adjaecnt vertex. So, if the counter becomes n — 1 and found an answer that an error.

This is my Wrong Accepted solution 121082526

The Hack Case:

10
1 5
1 2
3 6
3 9
3 4
4 5
6 7
7 8
9 10
2 2 1 1 2 1 2 2 1 2

For this data, The output should be NO. But My output is

YES
3

But here is another 121055514 solution which giving output NO.

So, here are two different solutions giving different outputs for the same valid input.

MikeMirzayanov Could you please check this.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

Автор PARTHO_DAS, история, 4 года назад, По-английски
I am trying to solve [E. Little Elephant and Inversions](https://codeforces.me/contest/220/problem/E)
But in the third test case : 
7 3
1 7 6 4 9 5 3
The expected output is: 6
But I can't understand how it's possible, in my logic I find the answer is: 15

7 3
1 7 6 4 9 5 3
-------------
0 1 2 3 4 5 6 // i
I find : 
5 3       || l = 5, r = 6
9 5 3     || l = 4, r = 6
9 5       || l = 4, r = 5
4 9 5     || l = 3, r = 5
4 9       || l = 3, r = 4
6 4 9 5   || l = 2, r = 5
6 4 9     || l = 2, r = 4
6 4       || l = 2, r = 3
7 6 4 9   || l = 1, r = 4
7 6 4     || l = 1, 4 = 3
7 6       || l = 1, r = 2
1 7 6 4 9 || l = 0, r = 4
1 7 6 4   || l = 0, r = 3
1 7 6     || l = 0, r = 2
1 7       || l = 0, r = 1
----------------------------
15 unique l and r, where inversions count is less than or equal to 3.

[My submission](https://codeforces.me/contest/220/submission/96186615)

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

Автор PARTHO_DAS, история, 5 лет назад, По-английски

I am a noob programmer but my I accepted a problem in CF global round 5. But in the main test got no verdict at that problem then I clicked on my profile submission and I saw runtime error in case no: 1 how this is possible? It comes runtime error in CF in the main test case 1 but in but pretest it was fine in pre-test. it also works fine in ideone. problem link https://codeforces.me/contest/1237/problem/B?statementsLocale=en my solution. https://ideone.com/prrXp7

Полный текст и комментарии »

  • Проголосовать: нравится
  • +11
  • Проголосовать: не нравится