at the last "Div 2" round i sent solution for problem B but i get Wrong answer on test 2 ....I spend a lot of time try to discover why my idea is wrong?!! actually my idea and my code was true , but because (sqrt function do not work in GNU 20 with long long number and same function work with GNU 17 i get wrong answer and my rate will decrase more than 150 point,** so please if you know some issues like this, please type it in the comment to know it , especially in differences between these two compilers**
my code AC on GNU 17 , WA on GNU 20
Auto comment: topic has been updated by AL-Yassin-105 (previous revision, new revision, compare).
You could've evaded it using sqrtl as 198837320 or implementing sqrt using binary search.
However, this issue is old. There is a separate blog I wrote abt before.
thanks , and i want to know if there are more differences , there was another issue in another problem in that time i do not know what the difference between them
Never mind bro, you can rise again next contest , just never give up :)
thanks for your support , inshallah both of us will do
You can't write a struct name as data and pass it as a parameter of a function. It will run in C++14 but give errors in C++17 and C++20.
Here is an example code:
It will run in C++14. But give errors in C++17 and C++20.
I faced this problem in the ICPC2022 preliminary round to solve the problem of Proximity Card Data Statistics. I used the struct name as data and pass it into a function, as a result, I was getting a Compilation error in the contest. But my code was smoothly running on my local pc. As a result, I lose 45 minutes of figuring out the problem.
do you mean data is a key word ?! in c++17 and c++20 !?
No, data isn't a keyword. You can use it as a variable. i.e
You can run it in C++14, C++17, C++20, etc. But when you use data as a struct name and pass it to a function as the parameter (I mention it in a previous comment) then it won't work in C++17 and C++20 (As I tested it in C++14, C++17, and C++20).
And it is happening because, In C++14, it is allowed to omit the struct/union/class keyword when referring to a member of a struct/union/class, as long as the intended member is not a type name. This is called "implicit conversion from class to its first data member" and is a language feature. However, in C++17 and C++20, this feature was removed due to inconsistency in the language and potential conflicting interpretations by different compilers. As a result, using a struct name as data and passing it as a parameter of a function is no longer allowed in these newer versions of C++.
thanks you bro
You can't use
data
because it is declared in C++ std namespace. However, if you change function sum toIt will be compiled without any problems
Yes, It will be compiled without any problems. Thank you for bringing up this idea.
it's your mistake not anyone else you should know every thing about the function you use in your code