Advertisement
Dmaxiya

红黑树 参考代码

Apr 12th, 2025
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long LL;
  5. const int maxn = 10 + 100;
  6. int n, row, col;
  7.  
  8. int dfs(int row, int col) {
  9.     if (row == 0) {
  10.         return 0;
  11.     }
  12.     int tmp = dfs(row - 1, col >> 1);
  13.     if (col & 1) {
  14.         tmp ^= 1;
  15.     }
  16.     return tmp;
  17. }
  18.  
  19. int main() {
  20. #ifdef ExRoc
  21.     freopen("test.txt", "r", stdin);
  22. #endif // ExRoc
  23.  
  24.     cin >> n;
  25.     while (n--) {
  26.         cin >> row >> col;
  27.         int ans = dfs(row - 1, col - 1);
  28.         cout << (ans == 0 ? "RED" : "BLACK ") << endl;
  29.     }
  30.  
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement