Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <string>
- #include <map>
- #include <algorithm>
- #include <fstream>
- #include <queue>
- #include <cmath>
- #include <unordered_map>
- using namespace std;
- #define endl '\n'
- struct point {
- long long x, y, num;
- point(long long x = 0, long long y = 0, long long num = 0) : x(x), y(y), num(num) {}
- };
- long long len(point a) {
- return a.x * a.x + a.y * a.y;
- }
- bool cmp(point a, point b) {
- return len(a) > len(b);
- }
- point operator+(point a, point b) {
- point tmp;
- tmp.x = a.x + b.x;
- tmp.y = a.y + b.y;
- return tmp;
- }
- point operator-(point a, point b) {
- point tmp;
- tmp.x = a.x - b.x;
- tmp.y = a.y - b.y;
- return tmp;
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int n;
- cin >> n;
- vector<point> shit(n);
- vector<point> data(n);
- for (int i = 0; i < n; i++) {
- cin >> data[i].x >> data[i].y;
- shit[i] = data[i];
- data[i].num = i;
- }
- vector<int> ans(n);
- for (int i = 0; i < 100; i++) {
- random_shuffle(data.begin(),data.end());
- point s = point(0, 0);
- for (int i = 0; i < n; i++) {
- if (len(s + data[i]) <= len(s - data[i])) {
- s = s + data[i];
- ans[data[i].num] = 1;
- }
- else {
- s = s - data[i];
- ans[data[i].num] = -1;
- }
- }
- if (len(s) <= 1500000ll * 1500000ll) {
- break;
- }
- }
- for (int i = 0; i < n; i++) {
- cout << ans[i] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement