Created
July 12, 2014 13:35
-
-
Save asi1024/d6b41d99951608d4ea8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
int n, m; | |
while (cin >> n >> m, n) { | |
vector<C> circle(n); | |
vector<P> point(m); | |
ld x, y, r; | |
REP(i,n) { | |
cin >> x >> y >> r; | |
circle[i] = (C){P(x, y), r}; | |
} | |
REP(zzz,m) { | |
P p, q; | |
cin >> x >> y; | |
p = P(x, y); | |
cin >> x >> y; | |
q = P(x, y); | |
bool res = true; | |
int cnt = 0; | |
REP(i,n) { | |
if ((abs(p - circle[i].p) < circle[i].r) | |
!= (abs(q - circle[i].p) < circle[i].r)) res = false; | |
if ((abs(p - circle[i].p) < circle[i].r) | |
&& (abs(q - circle[i].p) < circle[i].r)) cnt++; | |
} | |
if (cnt >= 1 && res) { | |
if (zzz > 0) cout << " "; | |
cout << "YES"; | |
continue; | |
} | |
vector<vector<tuple<ld,int,P> > > angle(n); | |
REP(i,n) REP(j,i) { | |
VP cr = is_cc(circle[i], circle[j]); // is_ccは円と円の交点を求める関数 | |
REP(k,cr.size()) { | |
angle[i].emplace_back(arg(cr[k] - circle[i].p), j, cr[k]); | |
angle[j].emplace_back(arg(cr[k] - circle[j].p), i, cr[k]); | |
} | |
} | |
REP(i,n) sort(ALL(angle[i])); | |
vector<vector<bool> > visited(n); | |
REP(i,n) visited[i].assign(angle[i].size(), 0); | |
REP(i,n) REP(j,visited[i].size()) { | |
int ii = i, jj = j; | |
VP vp; | |
while (true) { | |
if (get<1>(angle[ii][jj]) == get<1>(angle[ii][(jj+1)%visited[ii].size()])) jj = (jj + 1) % visited[ii].size(); | |
if (visited[ii][jj]) break; | |
vp.push_back(get<2>(angle[ii][jj])); | |
visited[ii][jj] = true; | |
jj = (jj + 1) % visited[ii].size(); | |
int dest = get<1>(angle[ii][jj]); | |
REP(k,angle[dest].size()) { | |
if (get<1>(angle[dest][k]) == ii) { | |
ii = dest; | |
jj = k; | |
break; | |
} | |
} | |
} | |
if (is_in_Polygon(vp, p) != is_in_Polygon(vp, q)) res = false; | |
} | |
if (zzz > 0) cout << " "; | |
cout << (res ? "YES" : "NO"); | |
} | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment