Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPIJudge failed to run C++ test 'count_inversions.exe' with MSVC on windows #220

Open
spacelg opened this issue Oct 25, 2021 · 1 comment

Comments

@spacelg
Copy link

spacelg commented Oct 25, 2021

Hi All,

Environment:
VS 2019 + Windows Server 2016

EPIJudge failed to run C++ test 'count_inversions.exe' with MSVC on windows. It can be reproduced on latest version b736406 on master branch. Could you please help look at this issue?

Repro steps:

  1. git clone https://github.com/adnanaziz/EPIJudge F:\gitP\adnanaziz\EPIJudge
  2. cd F:\gitP\adnanaziz\EPIJudge\epi_judge_cpp_solutions && mkdir build_amd64
  3. cd build_amd64
  4. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release ..
  5. msbuild /m /p:Platform=x64 /p:Configuration=Release epi_judge_cpp_solutions.sln /t:Rebuild
  6. cd F:\gitP\adnanaziz\EPIJudge\epi_judge_cpp_solutions\build_amd64\Release
  7. .\count_inversions.exe

Error info:
1015_releae

@spacelg
Copy link
Author

spacelg commented Oct 25, 2021

We can fix this test issue as below.

This function (in count_inversions.cc):
int CountSubarrayInversions(int start, int finish, vector* A_ptr) {

has several function calls in one expression. Compiler is allowed to call those fuctions in any order.
If you re-write the function like this:

int CountSubarrayInversions(int start, int finish, vector* A_ptr) {
if (finish - start <= 1) {
return 0;
}

int mid = start + ((finish - start) / 2);
int res = CountSubarrayInversions(start, mid, A_ptr);
res += CountSubarrayInversions(mid, finish, A_ptr);
res += MergeSortAndCountInversionsAcrossSubarrays(start, mid, finish, A_ptr);

return res;
}

Test passes with optimizations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant