1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
| #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <stack> #include <vector>
#define maxn 100005 using namespace std; int n; double l[maxn]; const double eps = 1e-8;
int sgn(double x) { if (fabs(x) < eps) return 0;
return x > 0 ? 1 : -1; }
double sqrtV(double len) { return len / sqrt(2.0); }
struct Point { int id; double x, y;
Point() {}
Point(double _x, double _y) { x = _x; y = _y; }
Point(double _x, double _y, int _id) { x = _x; y = _y; id = _id; }
Point(Point _p, int _id) { x = _p.x; y = _p.y; id = _id; }
bool operator<(const Point &A) { return sgn(x - A.x) == 0 ? y < A.y : x < A.x; }
bool operator==(const Point &A) { return sgn(x - A.x) == 0 && sgn(y - A.y) == 0; }
double operator^(const Point &A) { return x * A.y - y * A.x; }
double operator*(const Point &A) { return x * A.x + y * A.y; }
Point operator-(const Point &A) { return Point(x - A.x, y - A.y); }
void print() { printf("[Point] x:%.2lf, y:%.2lf id:%d\n", x, y, id); } };
struct Line { int id, ty; Point s, e;
Line() {}
Line(Point _s, Point _e) { s = _s; e = _e; }
Line(Point _s, Point _e, int _id, int _ty) { s = _s; e = _e; id = _id; ty = _ty; }
int segcrossseg(Line v) { int d1 = sgn((e - s) ^ (v.s - s)); int d2 = sgn((e - s) ^ (v.e - s)); int d3 = sgn((v.e - v.s) ^ (s - v.s)); int d4 = sgn((v.e - v.s) ^ (e - v.s));
if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;
return (d1 == 0 && sgn((v.s - s) * (v.s - e)) <= 0) || (d2 == 0 && sgn((v.e - s) * (v.e - e)) <= 0) || (d3 == 0 && sgn((s - v.s) * (s - v.e)) <= 0) || (d4 == 0 && sgn((e - v.s) * (e - v.e)) <= 0); } };
struct Segment { int id; double y; double lf, rt; } SM[maxn];
bool cmp(const Segment &A, const Segment &B) { return A.y > B.y; }
vector<Point> Si;
Point calc_m(Point s, double len) { double mv = sqrtV(len); return Point(s.x + mv, s.y + mv); }
Point calc_t(Point s, double len) { double mv = sqrtV(len) * 2; return Point(s.x, s.y + mv); }
bool check(Point s, double len) { Line newV = Line(s, Point(s.x - sqrtV(len), s.y + sqrtV(len)));
for (int i = 0; i < Si.size(); i++) { Point low = Si[i], up = Point(Si[i].x, 2 * sqrtV(l[Si[i].id]));
if (newV.segcrossseg(Line(low, up)) == 2) return false; }
return true; }
int main(void) { while (cin >> n && n) { Si.clear();
for (int i = 1; i <= n; i++) cin >> l[i];
double init_x = sqrtV(l[1]), init_y = 0; Si.push_back(Point(init_x, init_y, 1)); int now = 2;
while (now <= n) { int flag = 0, nsi = now - 1;
while (!flag && nsi > 0) { nsi--; Point nowSi = Si[nsi]; double nowLen = l[nsi + 1];
if (sgn(calc_m(nowSi, nowLen).y - sqrtV(l[now])) >= 0) { Point bas = calc_m(nowSi, nowLen); Point ret = Point(bas.x + sqrtV(l[now]), bas.y - sqrtV(l[now])); double delta = ret.y; Si.push_back(Point(ret.x - delta, ret.y - delta, now)); now++; flag = 1; } else if (check(Point(nowSi.x + 2 * sqrtV(nowLen), 0), l[now])) { Point bas = nowSi; double rl = sqrtV(nowLen); Si.push_back(Point(bas.x + 2 * rl, 0, now)); now++; flag = 1; } }
if (!flag) { Si.push_back(Point(sqrtV(l[now]), 0, now)); now++; } }
for (int i = 0; i < n; i++) { SM[i].lf = Si[i].x - sqrtV(l[Si[i].id]); SM[i].rt = Si[i].x + sqrtV(l[Si[i].id]); SM[i].y = l[Si[i].id]; SM[i].id = Si[i].id; }
sort(SM, SM + n, cmp); vector<int> ans; double maxr = -1e9;
for (int i = 0; i < n; i++) { double nlf = SM[i].lf, nrt = SM[i].rt;
for (int j = 0; j < i; j++) { if (sgn(SM[j].y - SM[i].y) > 0) { if (nlf >= SM[j].lf) nlf = max(nlf, SM[j].rt);
if (nrt <= SM[j].rt) nrt = min(nrt, SM[j].lf); } }
if (sgn(nrt - nlf) > 0) { ans.push_back(SM[i].id); } }
sort(ans.begin(), ans.end());
for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
cout << '\n'; }
return 0; }
|