Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define dbg(x) cerr<<#x": "<<x<<"\n"
  4. #define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
  5. #define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
  6. #define dbg_ok cerr<<"OK!\n"
  7.  
  8. #define st first
  9. #define nd second
  10.  
  11. using namespace std;
  12.  
  13. long long n, k, xt1, yt1, xt2, yt2, x[100100], y[100100];
  14.  
  15. template<class T>
  16. ostream& operator<<(ostream& out, vector<T> v) {
  17. for(auto e : v) out << e << ' ';
  18. return out;
  19. }
  20.  
  21. vector <long long> ans;
  22.  
  23. long long norm(long long x, long long y) {
  24. return x * x + y * y;
  25. }
  26.  
  27. int main() {
  28. ios_base::sync_with_stdio(false);
  29. cin >> n;
  30.  
  31. for(long long i = 1; i <= n; i++) {
  32. cin >> x[i] >> y[i];
  33.  
  34. xt1 += x[i];
  35. yt1 += y[i];
  36.  
  37. xt2 -= x[i];
  38. yt2 -= y[i];
  39. if(norm(xt1, yt1) < norm(xt2, yt2)) {
  40. xt2 = xt1;
  41. yt2 = yt1;
  42. ans.push_back(1);
  43. } else {
  44. xt1 = xt2;
  45. yt1 = yt2;
  46. ans.push_back(-1);
  47. }
  48. }
  49.  
  50. if(norm(xt1,yt1) <= 1500000000000LL) {
  51. cout << ans << '\n';
  52. return 0;
  53. }
  54.  
  55.  
  56. while(true) {
  57. long long xt, yt = 0;
  58. ans.clear();
  59. for(long long i = 1; i <= n; i++) {
  60.  
  61. if(rand() % 2)
  62. ans.push_back(1);
  63. else
  64. ans.push_back(-1);
  65.  
  66. xt += ans.back() * x[i];
  67. yt += ans.back() * y[i];
  68. }
  69.  
  70. if(norm(xt, yt) <= 1500000000000LL) {
  71. cout << ans << '\n';
  72. return 0;
  73. }
  74. }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement