Language: C++

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>

using namespace std;
int n,m;
int x[10000],y[10000],r[10000]; //???????????????
int G[100][100]; //??°???????????£??\??????
vector<vector<int> > C; //??°????????????????????¨???

int norm(int vx,int vy){ //???????????????
  return vx*vx+vy*vy;
}

bool isin(int px,int py,int id){ //???id???(px,py)?????\??£??????????????????
  if(norm(px-x[id],py-y[id])<=r[id]*r[id]) return true;
  return false;
}

bool iseq(vector<int> s,vector<int> t){ //??????s??¨??????t?????????????????????
  if(s.size()!=t.size()) return false;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  for(int i=0;i<s.size();++i) if(s[i]!=t[i]) return false;
  return true;
}

bool iscross(int i,int j){ //???i??¨???j??????????????????????????????
  if(sqrt(norm(x[i]-x[j],y[i]-y[j]))<=r[i]+r[j]) return true;
  return false;
}

void makegraph(){ //??°???????????????
  for(int i=0;i<n;++i)
    for(int j=i+1;j<n;++j)
      if(iscross(i,j)) G[i][j] = G[j][i] = 1;
}

bool visited[100];
int pre[100];
//int used[1<<20];

void dfs(int node,int from){ //??????3??\?????????????????¨?????????
  int tmp = pre[node];
  pre[node] = from;
  if(visited[node]){
    vector<int> cc; //??????
    cc.push_back(node);
    int now = from;
    for(int now=from;now!=node;now=pre[now]) cc.push_back(now);
    if(cc.size()>2){
      int a=0;
      for(int i=0;i<cc.size();++i) a+=1<<cc[i];
      bool f = true;
      for(int i=0;i<C.size();++i) if(iseq(cc,C[i])) f=false;
      if(f) C.push_back(cc);
      //      used[a] = 1;
    }
  }
  else{
    visited[node]=true;
    for(int i=0;i<n;++i) if(G[node][i] && i!=from) dfs(i,node);
    visited[node]=false;
  }
  pre[node] = tmp;
}

int cross(int ax,int ay,int bx,int by){
  return ax*by-ay*bx;
}

int dot(int ax,int ay,int bx,int by){
  return ax*bx+ay*by;
}

bool isinP(int px,int py,vector<int> Poly){ //????§???¢Poly???(px,py)?????????????????????
  bool in = false;
  int N = Poly.size();
  for(int i=0;i<N;++i){
    int ax = x[Poly[i]]-px;
    int ay = y[Poly[i]]-py;
    int bx = x[Poly[(i+1)%N]]-px;
    int by = y[Poly[(i+1)%N]]-py;
    if(ay > by){
      swap(ax,bx);
      swap(ay,by);
    }
    if(ay<=0 && 0<by)
      if(cross(ax,ay,bx,by)<0) in=!in;
    if(cross(ax,ay,bx,by)==0 && dot(ax,ay,bx,by)<=0) return true;
  }
  return in;
}

int searchcycle(int px,int py){ //(px,py)???????????????????§???¢?????¢???
  int N = C.size();
  for(int i=0;i<N;++i)
    if(isinP(px,py,C[i])) return i;
  return -1;
}

int main(){
  while(cin>>n>>m,n||m){
    for(int i=0;i<n;++i) cin>>x[i]>>y[i]>>r[i];
    //    memset(used,0,sizeof(used));
    memset(visited,0,sizeof(visited));
    memset(G,0,sizeof(G));
    C.clear();
    makegraph();
    dfs(0,-1);
    for(int i=0;i<m;++i){
      int sx,sy,tx,ty;
      cin>>sx>>sy>>tx>>ty;
      vector<int> s,t;
      for(int j=0;j<n;++j){
	if(isin(sx,sy,j)) s.push_back(j);
	if(isin(tx,ty,j)) t.push_back(j);
      }
      if(s.empty() && t.empty()){
	int id1 = searchcycle(sx,sy);
	int id2 = searchcycle(tx,ty);
	if(id1!=id2) cout << "NO ";
	else cout << "YES ";
      }
      else if(iseq(s,t)) cout << "YES ";
      else cout << "NO ";
    }
    cout << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:108:5: error: 'memset' was not declared in this scope
  108 |     memset(visited,0,sizeof(visited));
      |     ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <cmath>
  +++ |+#include <cstring>
    6 |