bool_bool

codeforces1270E.cpp

Jan 11th, 2020
956
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define all(v) v.begin(), v.end()
  5. #define Chrono chrono::steady_clock::now().time_since_epoch().count()
  6. #define dist2D(x1, y1, x2, y2) ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
  7. #define dist3D(x1, y1, z1, x2, y2, z2) ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2))
  8. #define EPS 1e-15
  9. #define eb emplace_back
  10. #define endl "\n"
  11. #define FastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  12. #define FI freopen("in.txt", "r", stdin)
  13. #define FO freopen("out.txt", "w", stdout)
  14. #define ff first
  15. #define gt(i, x) get<i>(x)
  16. #define INF 1000000000000000000
  17. #define ld long double
  18. #define ll long long
  19. #define mem(x,y) memset(x, y, sizeof x)
  20. #define mp make_pair
  21. #define mt make_tuple
  22. #define msi map<string, int>
  23. #define mii map<int, int>
  24. #define mis map<int, string>
  25. #define MOD 998244353
  26. #define PI acos(-1.0)
  27. #define PQ priority_queue
  28. #define pb push_back
  29. #define pib pair<int, bool>
  30. #define pii pair<int, int>
  31. #define iii pair<int, pii>
  32. #define iiii pair<pii, pii>
  33. #define pll pair<ll, ll>
  34. #define present(c, x) ((c).find(x) != (c).end())
  35. #define sfi(x) scanf("%d", &x)
  36. #define sfii(x,y) scanf("%d %d", &x, &y)
  37. #define sfiii(x,y,z) scanf("%d %d %d", &x, &y, &z)
  38. #define siz(x) (int)x.size()
  39. #define ss second
  40. #define tii tuple<int, int>
  41. #define tiii tuple<int, int, int>
  42. #define tiiii tuple<int, int, int, int>
  43. #define timeTaken endd = clock(); cerr << (double) (endd - beginn) / CLOCKS_PER_SEC * 1000 << endl
  44. #define timeInit clock_t beginn = clock(), endd
  45. #define ull unsigned long long
  46. #define umsi unordered_map<string, int>
  47. #define umii unordered_map<int, int>
  48. #define umis unordered_map<int, string>
  49. #define vb vector<bool>
  50. #define vi vector<int>
  51. #define vvi vector<vi>
  52. #define vii vector<pii>
  53. #define vvii vector<vii>
  54. #define vll vector<ll>
  55. #define vvll vector<vll>
  56. #define vpll vector<pll>
  57. #define bug(...) cerr << __LINE__ << " : (" << #__VA_ARGS__ << ") = ("; _Print(__VA_ARGS__);
  58. template<class T> void _Print(T &&x) { cerr << x << ")" << endl; }
  59. template<class T, class ...S> void _Print(T &&x, S &&...y) { cerr << x << ", "; _Print(y...); }
  60.  
  61. /*
  62. #include <ext/pb_ds/assoc_container.hpp>
  63. #include <ext/pb_ds/tree_policy.hpp>
  64. #include <functional>
  65. using namespace __gnu_pbds;
  66. typedef tree<int,null_type, less<int>, rb_tree_tag,
  67. tree_order_statistics_node_update> ordered_set;
  68.  
  69. //os.order_of_key(v): returns how many elements strictly less than v
  70. //os.find_by_order(k - 1): returns kth smallest element's iterator
  71. */
  72.  
  73. template<class T> class compare {
  74. public:
  75. bool operator() (pair<T, T> &x, pair<T, T> &y) {
  76. if (x.first == y.first) {
  77. return x.ss > y.ss;
  78. }
  79. return x.ff > y.ff;
  80. }
  81. };
  82.  
  83. template<class T> ostream &operator<<(ostream &os, const pair<T, T> &a) { return os << a.ff << " " << a.ss; }
  84. ll power(ll a, int b) {
  85. ll po = 1;
  86. while (b) {
  87. if (b & 1)
  88. po *= a;
  89. a *= a;
  90. b >>= 1;
  91. }
  92. return po;
  93. }
  94.  
  95. template<class T> pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return {a.ff + b.ff, a.ss + b.ss}; }
  96. template<class T> pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return {a.ff - b.ff, a.ss - b.ss}; }
  97. template<class T> pair<T, T> operator*(const pair<T, T> &a, const pair<T, T> &b) { return {a.ff * b.ff, a.ss * b.ss}; }
  98. template<class T> pair<T, T> operator%(const pair<T, T> &a, const pair<T, T> &b) { return {a.ff % b.ff, a.ss % b.ss}; }
  99. template<class T, class U> pair<T, T> operator+(const pair<T, T> &a, const U &b) { return {a.ff + b, a.ss + b}; }
  100. template<class T, class U> pair<T, T> operator*(const pair<T, T> &a, const U &b) { return {a.ff * b, a.ss * b}; }
  101.  
  102. int Set(int N, int pos) { return N = N | (1 << pos); }
  103. int reset(int N, int pos){ return N = N & ~ (1 << pos); }
  104. bool check(int N, int pos){ return (bool) (N & (1 << pos)); }
  105.  
  106. ///=======================================template=======================================///
  107.  
  108. int main() {
  109. //FI;//FO;
  110. FastIO; //timeInit;
  111.  
  112. int n;
  113. cin >> n;
  114. vii points(n);
  115.  
  116. for (auto &x : points) {
  117. cin >> x.ff >> x.ss;
  118. x.ff += 1000000;
  119. x.ss += 1000000;
  120. }
  121. vi ans;
  122.  
  123. while (true) {
  124. vvi cnt(2, vi(2, 0));
  125.  
  126. for (auto &x : points) {
  127. cnt[abs(x.ff) & 1][abs(x.ss) &1]++;
  128. }
  129.  
  130. if (cnt[0][0] + cnt[1][1] > 0 and cnt[0][1] + cnt[1][0] > 0) {
  131. for (int i = 0; i < siz(points); i++) {
  132. int val = (abs(points[i].ff) & 1) + (abs(points[i].ss) & 1);
  133. if (val & 1) {
  134. ans.eb(i + 1);
  135. }
  136. }
  137. //bug(1);
  138. break;
  139. }
  140.  
  141. if (cnt[0][0] > 0 and cnt[1][1] > 0) {
  142. for (int i = 0; i < siz(points); i++) {
  143. int val = (abs(points[i].ff) & 1) + (abs(points[i].ss) & 1);
  144. if (val == 0) {
  145. ans.eb(i + 1);
  146. }
  147. }
  148. break;
  149. }
  150.  
  151. if (cnt[0][1] > 0 and cnt[1][0] > 0) {
  152. for (int i = 0; i < siz(points); i++) {
  153. if ((abs(points[i].ff) & 1) == 0 and (abs(points[i].ss) & 1) == 1) {
  154. ans.eb(i + 1);
  155. }
  156. }
  157. break;
  158. }
  159.  
  160. for (auto &x : points) {
  161. x.ff /= 2;
  162. x.ss /= 2;
  163. }
  164. }
  165.  
  166. cout << siz(ans) << endl;
  167. for (auto &x : ans) {
  168. cout << x << " ";
  169. }
  170.  
  171. //timeTaken;
  172. return 0;
  173. }
Advertisement
Add Comment
Please, Sign In to add comment