fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <vector>
  4. #include <cstdio>
  5. #include <ios>
  6. #include <map>
  7. #include <set>
  8. #include <algorithm>
  9. #include <cstring>
  10. #include <ctime>
  11. #include <queue>
  12. #include <cassert>
  13. #include <cmath>
  14. #include <string>
  15. #include <stack>
  16.  
  17. using namespace std;
  18. typedef long long ll;
  19. typedef pair<int, int> pi;
  20.  
  21.  
  22. vector< pi > v;
  23.  
  24. int assign(int cur, int l, int r){
  25. if(l == r){
  26. v.push_back(pi(-1, -1));
  27. return v.size() - 1;
  28. }
  29. int mid = (l+r) >> 1;
  30. int pos = v.size();
  31. v.push_back(pi(-1, -1));
  32. int lIdx = assign(cur<<1, l, mid);
  33. int rIdx = assign((cur<<1) + 1, mid+1, r);
  34. v[pos].first = lIdx;
  35. v[pos].second = rIdx;
  36. cout << v[pos].first << " " << v[pos].second << endl;
  37. return pos;
  38. }
  39.  
  40.  
  41. int main() {
  42. #ifndef ONLINE_JUDGE
  43. freopen("in.in", "r", stdin);
  44. #endif
  45.  
  46. assign(1, 0, 10);
  47.  
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
4 5
3 6
9 10
8 11
2 7
15 16
14 17
19 20
13 18
1 12