Advertisement
Guest User

Untitled

a guest
Sep 10th, 2015
2,248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4.  
  5. #include <vector>
  6. #include <set>
  7. #include <bitset>
  8. #include <map>
  9. #include <deque>
  10. #include <string>
  11.  
  12. #include <algorithm>
  13. #include <numeric>
  14.  
  15. #include <cstdio>
  16. #include <cassert>
  17. #include <cstdlib>
  18. #include <cstring>
  19. #include <ctime>
  20. #include <cmath>
  21.  
  22. #define pb push_back
  23. #define pbk pop_back
  24. #define mp make_pair
  25. #define fs first
  26. #define sc second
  27. #define all(x) (x).begin(), (x).end()
  28. #define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
  29. #define len(a) ((int) (a).size())
  30.  
  31. #ifdef CUTEBMAING
  32. #define eprintf(...) fprintf(stderr, __VA_ARGS__)
  33. #else
  34. #define eprintf(...) 42
  35. #endif
  36.  
  37. using namespace std;
  38.  
  39. typedef long long int64;
  40. typedef long double ld;
  41. typedef unsigned long long lint;
  42.  
  43. const int inf = (1 << 30) - 1;
  44. const int64 linf = (1ll << 62) - 1;
  45. const int C = 1000;
  46.  
  47. int main() {
  48.     int n; cin >> n;
  49.     vector<pair<pair<int, int>, int>> points(n);
  50.     for (int i = 0; i < n; i++) {
  51.         scanf("%d%d", &points[i].fs.fs, &points[i].fs.sc);
  52.         points[i].sc = i;
  53.         points[i].fs.fs /= C;
  54.     }
  55.     sort(all(points), [](const pair<pair<int, int>, int> &a, const pair<pair<int, int>, int> &b) {
  56.         return a.fs.fs < b.fs.fs || (a.fs.fs == b.fs.fs && (a.fs.fs % 2 == 0 ? (a.fs.sc < b.fs.sc) : (a.fs.sc > b.fs.sc)));
  57.     });
  58.     for (auto i : points) {
  59.         printf("%d ", i.sc + 1);
  60.     }
  61.     puts("");
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement