#include<bits/stdc++.h>
using namespace std;
const int N = 10010, D = 20000;
int n, m, x, y, z, c[N], r[N], s[N];
vector<int> v[N<<2+1];
int main(){
cin>>n;
for (int i=1;i<=n; i++)
{
cin>>c[i]>>r[i];
c[i]+=D;
for(int j=c[i]-r[i];j<=c[i]+r[i];j++) v[j].push_back(i);
}
fill(s+1,s+n+1,-1);
cin >> m;
for (int i=1;i<=m;i++){
cin >> x >> y;
x+=D;
for (auto j:v[x])
if(s[j]==-1)
if (y*y+(x-c[j])*(x-c[j])<=r[j]*r[j]) s[j] = i,z++;
}
cout << z << endl;
for (int i=1;i<=n;i++) cout<<s[i]<<" ";
}
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |