-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30b109d
commit 9208996
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int solution(vector<vector<int>> Data, int Col, int RowBegin, int RowEnd) | ||
{ | ||
sort(Data.begin(), Data.end(), [&](const auto& Lhs, const auto& Rhs) | ||
{ | ||
return Lhs[Col - 1] == Rhs[Col - 1] ? Lhs[0] > Rhs[0] : Lhs[Col - 1] < Rhs[Col - 1]; | ||
}); | ||
|
||
int HashVal = 0; | ||
for(int i = RowBegin; i <= RowEnd; ++i) | ||
{ | ||
int S_i = 0; | ||
for(const int Val : Data[i - 1]) | ||
{ | ||
S_i += Val % i; | ||
} | ||
HashVal ^= S_i; | ||
} | ||
|
||
return HashVal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters