Problem:
風よ、私の梅の香りを届けておくれ！
引っ越しが決まり、この地を去ることになった。この土地自体に未練は無いが、１つだけ気になることがある。それは、庭に植えた梅の木のことだ。私は毎年、この梅が花を咲かすことを楽しみにしていた。ここを離れた後は春の楽しみが１つ減ってしまう。私の梅の香りだけでも風に乗って引っ越し先の家まで届き、春を楽しませてはくれないものか。
日本には春を象徴する３つの花がある。梅・桃・桜の３つだ。引っ越し先には、私の梅以外にも、これらの花の香りが届くだろう。しかし、私の梅の香りだけが届く日数が最も多い家に住みたい。
図のように、花の香りは扇状に広がり、その領域は風の向かう方向と強さによって決まる。扇形は風の向かう方向 w を中心にして対称に広がり、風の強さ a を半径とする領域をもつ。香りが広がる角度 d は花の種類によって決まっているが、風の向かう方向と強さは日によって異なる。ただし、同じ日では、すべての場所で風の向かう方向と強さは同じである。
手元には、私の梅以外の梅・桃・桜の位置と花の種類ごとの香りが広がる角度、引っ越し先の家の候補のデータがある。さらに、数日分の風の向かう方向と強さのデータもある。私の梅以外の梅・桃・桜の木と家の位置は、私の梅の位置を原点とした座標で示されている。
これらのデータを使って、私の梅の香りだけが届く日数の最も多い家を探すためのプログラムを書いてみることとしよう。私は有能なプログラマーなのだから！
入力
入力は複数のデータセットからなる。入力の終わりはゼロ２つの行で示される。各データセットは以下の形式で与えられる。
H R
hx
1
hy
1
hx
2
hy
2
:
hx
H
hy
H
U M S du dm ds
ux
1
uy
1
ux
2
uy
2
:
ux
U
uy
U
mx
1
my
1
mx
2
my
2
:
mx
M
my
M
sx
1
sy
1
sx
2
sy
2
:
sx
S
sy
S
w
1
a
1
w
2
a
2
:
w
R
a
R
各行で与えられる数値は１つの空白で区切られている。
１行目に引っ越し先の家の候補の数 H (1 ≤ H ≤ 100) と風の記録の数 R (1 ≤ R ≤ 100) が与えられる。続くH 行に引っ越し先の家の位置が与えられる。hx
i
とhy
i
は i 番目の家の x 座標と y 座標を示す-1000 以上1000 以下の整数である。
続く１行に、私の梅以外の梅の木の数 U と、桃・桜の木の数 M、S、梅・桃・桜の香りが広がる角度du、dm、ds が与えられる。U、M、S の範囲は 0 以上10 以下である。角度の単位は度であり、1 以上180 未満の整数である。
続く U 行に私の梅以外の梅の木の位置、続く M 行に桃の木の位置、続く S 行に桜の木の位置が与えられる。uxi と uyi、mxi と myi、sxi と syi はそれぞれ、i 番目の梅・桃・桜の木の x 座標と y 座標を示す、-1000 以上 1000 以下の整数である。
続く R 行に風の記録が与えられる。w
i
(0 ≤ w
i
< 360) と a
i
(0 < a
i
≤ 100) は i 日目の風の向かう方向と強さを表す整数である。風の向かう方向は、x 軸の正の向きから反時計回りに測った角度で表し、単位は度とする。
入力は以下の条件を満たすと考えてよい。
入力される座標はすべて異なるものとする。
原点には私の梅以外無い。
どの花についても、花の香りが届く領域の境界から距離が 0.001 以内には家は無い。
データセットの数は 50 を超えない。
出力
データセットごとに、私の梅の香りだけが届く日数の最も多い全ての家の番号を、小さい順に１行に出力する。家の番号の間は空白１つで区切る。行の終わりには空白文字を出力しない。
ただし、どの家についても、私の梅の花の香りだけが届く日が１日もなければ、NA と出力する。
入力例
6 3
2 1
1 2
5 2
1 3
1 5
-2 3
1 1 1 90 30 45
3 -4
-3 0
2 -2
45 6
90 6
135 6
2 1
1 3
5 2
0 1 1 90 30 45
-3 0
2 -2
45 6
0 0
出力例
5 6
NA

Submitted solutions:

code_snippet: #include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const double pi = acos(-1.0);
class point2d {
public:
	double x, y;
	point2d() : x(0.0), y(0.0) {};
	point2d(double x_, double y_) : x(x_), y(y_) {};
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	double abs() const { return sqrt(x * x + y * y); }
	double dot(const point2d& p) const { return x * p.x + y * p.y; }
	double cross(const point2d& p) const { return x * p.y - y * p.x; }
};
int main() {
	while (true) {
		int H, R, U, M, S, du, dm, ds;
		cin >> H >> R;
		if (H == 0 && R == 0) break;
		vector<point2d> hickosi(H);
		for (int i = 0; i < H; ++i) {
			cin >> hickosi[i].x >> hickosi[i].y;
		}
		cin >> U >> M >> S >> du >> dm >> ds;
		vector<point2d> pu(U), pm(M), ps(S);
		for (int i = 0; i < U; ++i) {
			cin >> pu[i].x >> pu[i].y;
		}
		for (int i = 0; i < M; ++i) {
			cin >> pm[i].x >> pm[i].y;
		}
		for (int i = 0; i < S; ++i) {
			cin >> ps[i].x >> ps[i].y;
		}
		vector<int> W(R), A(R);
		for (int i = 0; i < R; ++i) {
			cin >> W[i] >> A[i];
		}
		vector<int> ans(H);
		for (int i = 0; i < H; ++i) {
			int days = 0;
			for (int j = 0; j < R; ++j) {
				double dangle = W[j] * pi / 180;
				vector<int> list;
				for (int k = 0; k < 1 + U + M + S; ++k) {
					point2d origin = (k == 0 ? point2d() : (k <= U ? pu[k - 1] : (k <= U + M ? pm[k - U - 1] : ps[k - U - M - 1])));
					double angle = (k <= U ? du : (k <= U + M ? dm : ds)) * pi / 180;
					double langle = dangle - angle / 2;
					double rangle = dangle + angle / 2;
					point2d lp(cos(langle), sin(langle));
					point2d rp(cos(rangle), sin(rangle));
					point2d vec = hickosi[i] - origin;
					if (vec.abs() <= A[j] && lp.cross(vec) >= 0.0 && rp.cross(vec) <= 0.0) {
						list.push_back(k);
					}
				}
				if (list == vector<int>({ 0 })) {
					++days;
				}
			}
			ans[i] = days;
		}
		int mx = *max_element(ans.begin(), ans.end());
		if (mx == 0) {
			cout << "NA" << endl;
		}
		else {
			int last = -1;
			for (int i = 0; i < H; ++i) {
				if (ans[i] == mx) {
					if (last != -1) cout << ' ';
					cout << i + 1;
					last = i;
				}
			}
			cout << endl;
		}
	}
	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3580
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;

struct Tree{
	double x, y, d;
	
	Tree(int xx, int yy, int dd){
		x = xx;
		y = yy;
		d = dd;
	}

	bool isOK(double hx, double hy, double w, double a){
		double l = w - d/2;
		double r = w + d/2;
		l += 360 * 4;
		r += 360 * 4;
		
		double kaku = atan2((hy-y),(hx-x)) * 180/M_PI;
		
		while(l > kaku){
			kaku += 360;
		}
		
		if(r < kaku){
			return false;
		}

		if(a*a >= (hy-y)*(hy-y) + (hx-x) * (hx-x)){
			return true;
		}
		return false;

	}
};

	


int main(){

	int h, r;
	while(cin >> h >> r, h != 0){
		int x[110], y[110];
		for(int i = 0;i < h;i++) cin >> x[i] >> y[i];

		int U, M, S, du, dm, ds;
		cin >> U >> M >> S >> du >> dm >> ds;

		Tree myTree(0, 0, du);
		
		vector<Tree> tree;
		for(int i = 0;i < U;i++){
			int x, y;
			cin >> x >> y;
			tree.push_back(Tree(x, y, du));
		}
		
		for(int i = 0;i < M;i++){
			int x, y;
			cin >> x >> y;
			tree.push_back(Tree(x, y, dm));
		}


		for(int i = 0;i < S;i++){
			int x, y;
			cin >> x >> y;
			tree.push_back(Tree(x, y, ds));
		}
		
		int n = U + M + S;

		int cnt[110] = {};
		
		for(int i = 0;i < r;i++){
			int w, a;
			cin >> w >> a
;			bool flag;
			for(int j = 0;j < h;j++){
				flag = false;
				for(int k = 0;k < n;k++){
					flag = (flag || tree[k].isOK(x[j], y[j], w, a));
				}
				if(!flag && myTree.isOK(x[j], y[j], w, a)){
					cnt[j]++;
				}
			}
		}

		vector<int> ans;
		int ans_num = 0;
		for(int i = 0;i < h;i++){
			if(ans_num < cnt[i]){
				ans.clear();
				ans_num = cnt[i];
				ans.push_back(i+1);
			}else if(ans_num == cnt[i]){
				ans.push_back(i+1);
			}
		}

		if(ans_num == 0){
			cout << "NA" << endl;
		}else{
			for(int i = 0;i < ans.size();i++){
				cout << ans[i];
				if(i < ans.size()-1){
					cout << " ";
				}else{
					cout << endl;
				}
			}
		}
	}

	return 0;

}
accuracy: 1
time_ms: 20
memory_kb: 3388
final_rank: 9

code_snippet: #include <bits/stdc++.h>
 
using namespace std;
 
struct point {
    double x, y;
    int d;
};
 
bool check_dst(point home, point ums, double a) {
 
    double x = home.x - ums.x;
    double y = home.y - ums.y;
 
    return x * x + y * y <= a * a;
 
}
 
bool check_deg(point home, point ums, double w) {
 
    double x = home.x - ums.x;
    double y = home.y - ums.y;
    double home_deg;
    double start_deg = w - ums.d / 2.0;
    double end_deg = w + ums.d / 2.0;
 
    home_deg = atan2(y, x) * 180 / M_PI;
 
    if(home_deg < 0.0) {
        home_deg += 360.0;
    }
 
    if(0.0 <= start_deg && end_deg <= 360.0) {
        return start_deg <= home_deg && home_deg <= end_deg;
    } else if(start_deg < 0.0) {
        start_deg += 360.0;
        return start_deg <= home_deg || home_deg <= end_deg;
    } else { // end_deg > 360
        end_deg -= 360.0;
        return start_deg <= home_deg || home_deg <= end_deg;
    }
 
}

bool check_reach(point home, point ums, double w, double a) {
    return check_deg(home, ums, w) && check_dst(home, ums, a);
}
 
int main() {
 
    int h, r;
 
    while(cin >> h >> r, h || r) {
 
        int u, m, s;
        double du, dm, ds;
        vector<point> homes, ums;
 
        for(int i = 0; i < h; ++i) {
            double x, y;
            cin >> x >> y;
            homes.push_back((point){ x, y, 0 });
        }
 
        cin >> u >> m >> s;
        cin >> du >> dm >> ds;
 
        for(int i = 0; i < u + m + s; ++i) {
            double x, y;
            cin >> x >> y;
            if(i < u) {
                ums.push_back((point){ x, y, du });
            } else if(u <= i && i < u + m) {
                ums.push_back((point){ x, y, dm });
            } else {
                ums.push_back((point){ x, y, ds });
            }
        }
 
        for(int i = 0; i < r; ++i) {
            double w, a;
            cin >> w >> a;
            for(int j = 0; j < homes.size(); ++j) {
                bool is_perfect = check_reach(homes[j], (point){ 0, 0, du }, w, a);
                for(int k = 0; k < ums.size(); ++k) {
                    if(check_reach(homes[j], ums[k], w, a)) {
                        is_perfect = false;
                    }
                }
                homes[j].d += is_perfect;
            }
        }
 
        int max_day = 0;
        for(int i = 0; i < homes.size(); ++i) {
            max_day = max(max_day, homes[i].d);
        }
 
        if(max_day) {
            bool is_out = false;
            for(int i = 0; i < homes.size(); ++i) {
                if(homes[i].d == max_day) {
                    if(is_out) cout << " " << i + 1;
                    else cout << i + 1;
                    is_out = true;
                }
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
 
    }
 
}
accuracy: 1
time_ms: 20
memory_kb: 3468
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<double,double> P;
typedef complex<double> PP;
double toRad(double agl){return agl*M_PI/180.0;}
double D(P a,P b) {return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));}
PP rotate(PP a, double r){return PP(a.real()*cos(r)-a.imag()*sin(r),a.real()*sin(r)+a.imag()*cos(r));}

bool solve(P a,P c,P b,double d) {
  double r=atan2(a.S-b.S,a.F-b.F);
  PP a2=rotate(PP(c.S,0),toRad(c.F-d/2)),a3=rotate(PP(c.S,0),toRad(c.F+d/2));
  double rl=atan2(a2.imag(),a2.real()),rr=atan2(a3.imag(),a3.real());
  if(rr<rl) rr+=2*M_PI;
  if(D(a,b)<=c.S&&(rl<=r&&r<=rr||rl<=r+M_PI*2&&r+M_PI*2<=rr)) return 1;
  return 0;
}

int main() {
  int n,n2;
  while(cin >> n >> n2 && n) {
    P a[n];
    for(int i=0; i<n; i++) cin >> a[i].F >> a[i].S;
    int U,M,S,du,dm,ds;
    cin >> U >> M >> S >> du >> dm >> ds;
    P u[U],m[M],s[S];
    for(int i=0; i<U; i++) cin >> u[i].F >> u[i].S;
    for(int i=0; i<M; i++) cin >> m[i].F >> m[i].S;
    for(int i=0; i<S; i++) cin >> s[i].F >> s[i].S;
    P b[n2];
    for(int i=0; i<n2; i++) cin >> b[i].F >> b[i].S;
    int z=1;
    vector<int> ans;
    for(int i=0; i<n; i++) {
      int cnt=0;
      for(int j=0; j<n2; j++) {
        bool f=solve(a[i],b[j],P(0,0),du);
        for(int k=0; k<U; k++) {
          if(solve(a[i],b[j],u[k],du)) f=0;
        }
        for(int k=0; k<M; k++) {
          if(solve(a[i],b[j],m[k],dm)) f=0;
        }
        for(int k=0; k<S; k++) {
          if(solve(a[i],b[j],s[k],ds)) f=0;
        }
        cnt+=f;
      }
      if(cnt>z) {
        z=cnt;
        ans.clear();
        ans.push_back(i+1);
      } else if(cnt==z) ans.push_back(i+1);
    }
    if(!ans.size()) cout << "NA" << endl;
    else {
      for(int i=0; i<ans.size(); i++) {
        if(i) cout << " ";
        cout << ans[i];
      }
      cout << endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 3636
final_rank: 20

code_snippet: #include<bits/stdc++.h>
#define  Pi M_PI
using namespace std;
#define int long long
typedef complex <double> P;
double dot(P a,P b){return real(conj(a)*b);}
double cross(P a,P b){return imag(conj(a)*b);}
const double EPS  = 1e-8;

int ccw(P a,P b,P c){
  b-= a;
  c-=a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS ) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool check(P a,P t,double d,P h){
  if(abs(t-h) > abs(a)) return 0;
  h-=t;
  d/=2;
  d*= Pi/180;
  P A = a * P(cos(d),sin(d));
  P B = a * conj(P(cos(d),sin(d)));
  return ccw(P(0,0),A,h)!=1&&ccw(P(0,0),B,h)!=-1;
}

signed main(){
  while(1){
    int H,R;
    cin>>H>>R;
    if(!H&&!R)return 0;

    P house[101];
    for(int i=0;i<H;i++){
      double x,y;
      cin>>x>>y;
      house[i] = P(x,y);
    }

    int U,M,S;
    double du,dm,ds;
    cin>>U>>M>>S>>du>>dm>>ds;

    P UME[11],MO[11],SA[11];
    for(int i=0;i<U;i++){
      double x,y;
      cin>>x>>y;
      UME[i] = P(x,y);
    }

    for(int i=0;i<M;i++){
      double x,y;
      cin>>x>>y;
      MO[i] = P(x,y);
    }

    for(int i=0;i<S;i++){
      double x,y;
      cin>>x>>y;
      SA[i] = P(x,y);
    }

    int cnt[101]={};
    for(int i=0;i<R;i++){
      double w,d;
      cin>>w>>d;
      w*=Pi/180;
      P a = P(cos(w),sin(w))*d;
    
      for(int j=0;j<H;j++){
	bool flg = check(a,P(0,0),du,house[j]);
	for(int k=0;k<U;k++)flg &= !check(a,UME[k],du,house[j]);
	for(int k=0;k<M;k++)flg &= !check(a,MO[k],dm,house[j]);
	for(int k=0;k<S;k++)flg &= !check(a,SA[k],ds,house[j]);
	cnt[j] += flg;
      }
    }

    int mx = 0;
    for(int i=0;i<H;i++)mx = max(mx,cnt[i]);

    if(mx==0) {cout<<"NA"<<endl;continue;}

    int f=0;
    for(int i=0;i<H;i++){
      if(cnt[i] == mx) {
	if(f)cout<<" ";
	f = 1;
	cout<<i+1;
      }
    }
    cout<<endl;
  }
  
    
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3480
final_rank: 6

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

/* ??????????????¬ */

#include <complex>

typedef long double ld;
typedef complex<ld> Point;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()


const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;

namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		if (lhs.real() < rhs.real() - eps) return true;
		if (lhs.real() > rhs.real() + eps) return false;
		return lhs.imag() < rhs.imag();
	}
}

// ????????\???
Point input_point() {
	ld x, y;
	cin >> x >> y;
	return Point(x, y);
}

// ????????????????????????
bool eq(const ld a, const ld b) {
	return (abs(a - b) < eps);
}

// ??????
ld dot(const Point& a, const Point& b) {
	return real(conj(a) * b);
}

// ??????
ld cross(const Point& a, const Point& b) {
	return imag(conj(a) * b);
}

// ??´????????????
class Line {
public:
	Point a, b;
	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
	Point operator[](const int _num)const {
		if (_num == 0)return a;
		else if (_num == 1)return b;
		else {
			assert(false);
			return Point();
		}
	}
};

// ????????????
class Circle {
public:
	Point p;
	ld r;
	Circle() : p(Point(0, 0)), r(0) {}
	Circle(Point p, ld r) : p(p), r(r) {}
};

// CCW
int ccw(const Point& a, const Point &b, const Point &c) {
	const Point nb(b - a);
	const Point nc(c - a);
	if (cross(nb, nc) > eps) return 1;   // a,b,c??????????¨???¨?????????????????¶
	if (cross(nb, nc) < -eps) return -1; // a,b,c???????¨???¨?????????????????¶
	if (dot(nb, nc) < 0) return 2;       // c,a,b???????????´???????????¶
	if (norm(nb) < norm(nc)) return -2;  // a,b,c???????????´???????????¶
	return 0;                          // a,c,b???????????´???????????¶
}


/* ???????????? */

// ??´?????¨??´??????????????????
bool isis_ll(const Line& l, const Line& m) {
	return !eq(cross(l.b - l.a, m.b - m.a), 0);
}

// ??´?????¨?????????????????????
bool isis_ls(const Line& l, const Line& s) {
	return isis_ll(l, s) &&
		(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

// ????????¨?????????????????????
bool isis_ss(const Line& s, const Line& t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
		ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

// ????????´????????????
bool isis_lp(const Line& l, const Point& p) {
	return (abs(cross(l.b - p, l.a - p)) < eps);
}

// ?????????????????????
bool isis_sp(const Line& s, const Point& p) {
	return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}

// ??????????¶?
Point proj(const Line &l, const Point& p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}

// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line& t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line& t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	if (cross(sv, tv) != 0)return vector<Point>(1, is_ll(s, t));
	else {
		vector<Point>ans;
		for (int k = 0; k < 2; ++k) {
			if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())ans.push_back(t[k]);
			if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())ans.push_back(s[k]);
		}
		return ans;
	}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line& t) {
	if (isis_ss(s, t)) {
		for (int k = 0; k < 2; ++k) {
			for (int l = 0; l < 2; ++l) {
				if (s[k] == t[l])return s[k];
			}
		}
		return is_ll(s, t);
	}
	else {
		//??????isis_ss?????????
		assert(false);
		return Point(0, 0);
	}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line& t) {
	vector<Point> kouho(is_ll2(s, t));
	vector<Point>ans;
	for (auto p : kouho) {
		if (isis_sp(s, p) && isis_sp(t, p))ans.emplace_back(p);
	}
	return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line& l, const Point& p) {
	return abs(p - proj(l, p));
}

// ??´?????¨??´???????????¢
ld dist_ll(const Line& l, const Line& m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}

// ??´?????¨??????????????¢
ld dist_ls(const Line& l, const Line& s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}

// ????????¨???????????¢
ld dist_sp(const Line& s, const Point& p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

// ????????¨??????????????¢
ld dist_ss(const Line& s, const Line& t) {
	if (isis_ss(s, t)) return 0;
	return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}


//??´?????¨??´?????????????????????????????????
Line bisection(const Line &s, const Line &t) {
	const Point laglanju(is_ll(s, t));
	const Point avec = !(abs(laglanju - s[0])<eps) ? s[0] - laglanju : s[1] - laglanju;
	const Point bvec = !(abs(laglanju - t[0])<eps) ? t[0] - laglanju : t[1] - laglanju;

	return Line(laglanju, laglanju + (abs(bvec)*avec + abs(avec)*bvec) / (abs(avec) + abs(bvec)));
}


//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point  inner_center(const vector<Line>&ls) {
	vector<Point>vertics;
	for (int i = 0; i <static_cast<int>(ls.size()); ++i) {
		vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
	}
	if (vertics[0] == vertics[1] || vertics[1] == vertics[2] || vertics[2] == vertics[0])return vertics[0];
	Line bi1(bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
	Line bi2(bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
	if (bi1[0] == bi2[0])return bi1[0];
	else {
		return is_ll(bi1, bi2);
	}
}

//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point>  ex_center(const vector<Line>&ls) {
	vector<Point>vertics;
	for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
		vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
	}
	if (abs(vertics[0] - vertics[1])<eps || abs(vertics[1] - vertics[2])<eps || (abs(vertics[2] - vertics[0])<eps))return vector<Point>();
	vector<Point>ecs;
	for (int i = 0; i < 3; ++i) {
		Line bi1(bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[i], vertics[(i + 1) % 3])));
		Line bi2(bisection(Line(vertics[(i + 1) % 3], vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]), Line(vertics[(i + 1) % 3], vertics[i])));
		ecs.push_back(is_ll(bi1, bi2));
	}
	return ecs;
}


//a,b:??????
//c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point>  same_dis(const vector<Line>&ls) {
	vector<Point>vertics;
	vertics.push_back(is_ll(ls[0], ls[2]));
	vertics.push_back(is_ll(ls[1], ls[2]));

	if (abs(vertics[0] - vertics[1]) < eps)return vector<Point>{vertics[0]};
	Line bis(bisection(ls[0], ls[1]));
	vector<Point>ecs;

	Line abi(bisection(Line(vertics[0], vertics[1]), ls[0]));
	ecs.push_back(is_ll(bis, abi));


	Line bbi(bisection(Line(vertics[0], 2.l*vertics[0] - vertics[1]), ls[0]));
	ecs.push_back(is_ll(bis, bbi));

	return ecs;
}
/* ??? */

// ?????¨????????????
vector<Point> is_cc(const Circle& c1, const Circle& c2) {
	vector<Point> res;
	ld d = abs(c1.p - c2.p);
	ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
	ld dfr = c1.r * c1.r - rc * rc;
	if (abs(dfr) < eps) dfr = 0.0;
	else if (dfr < 0.0) return res; // no intersection
	ld rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff * Point(rc, rs));
	if (dfr != 0.0) res.push_back(c1.p + diff * Point(rc, -rs));
	return res;
}

//???????????????????????????
//  0 => out
//  1 => on
//  2 => in
int is_in_circle(const Circle &cir, const  Point& p) {
	ld dis = abs(cir.p - p);
	if (dis > cir.r + eps)return 0;
	else if (dis < cir.r - eps)return 2;
	else return 1;
}
//???lc??????rc??????????????????
//  0 => out
//  1 => on
//  2 => in
int circle_in_circle(const Circle &lc, const  Circle&rc) {
	ld dis = abs(lc.p - rc.p);
	if (dis < rc.r - lc.r - eps)return 2;
	else if (dis>rc.r - lc.r + eps)return 0;
	else return 1;
}

// ?????¨??´????????????
vector<Point> is_lc(const Circle& c, const Line& l) {
	vector<Point> res;
	ld d = dist_lp(l, c.p);
	if (d < c.r + eps) {
		ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); //safety;
		Point nor = (l.a - l.b) / abs(l.a - l.b);
		res.push_back(proj(l, c.p) + len * nor);
		res.push_back(proj(l, c.p) - len * nor);
	}
	return res;
}

// ?????¨??????????????¢
vector<Point> is_sc(const Circle& c, const Line& l) {
	vector<Point> v = is_lc(c, l), res;
	for (Point p : v)
		if (isis_sp(l, p)) res.push_back(p);
	return res;
}

// ?????¨????????\???
vector<Line> tangent_cp(const Circle& c, const Point& p) {
	vector<Line> ret;
	Point v = c.p - p;
	ld d = abs(v);
	ld l = sqrt(norm(v) - c.r * c.r);
	if (isnan(l)) { return ret; }
	Point v1 = v * Point(l / d, c.r / d);
	Point v2 = v * Point(l / d, -c.r / d);
	ret.push_back(Line(p, p + v1));
	if (l < eps) return ret;
	ret.push_back(Line(p, p + v2));
	return ret;
}

// ?????¨????????\???
vector<Line> tangent_cc(const Circle& c1, const Circle& c2) {
	vector<Line> ret;
	if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
		Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
		ret = tangent_cp(c1, center);
	}
	if (abs(c1.r - c2.r) > eps) {
		Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
		vector<Line> nret = tangent_cp(c1, out);
		ret.insert(ret.end(), ALL(nret));
	}
	else {
		Point v = c2.p - c1.p;
		v /= abs(v);
		Point q1 = c1.p + v * Point(0, 1) * c1.r;
		Point q2 = c1.p + v * Point(0, -1) * c1.r;
		ret.push_back(Line(q1, q1 + v));
		ret.push_back(Line(q2, q2 + v));
	}
	return ret;
}
//??????????????????????????¢???
ld two_circle_area(const Circle&l, const Circle&r) {
	ld dis = abs(l.p - r.p);
	if (dis > l.r + r.r)return 0;
	else if (dis + r.r < l.r) {
		return r.r*r.r*pi;
	}
	else if (dis + l.r < r.r) {
		return l.r*l.r*pi;
	}
	else {
		ld ans = (l.r)*(l.r)*acos((dis*dis + l.r*l.r - r.r*r.r) / (2 * dis*l.r)) +
			(r.r)*(r.r)*acos((dis*dis + r.r*r.r - l.r*l.r) / (2 * dis*r.r)) -
			sqrt(4 * dis*dis*l.r*l.r - (dis*dis + l.r*l.r - r.r*r.r)*(dis*dis + l.r*l.r - r.r*r.r)) / 2;
		return ans;
	}

}

/* ????§???¢ */

typedef vector<Point> Polygon;

// ??¢???
ld area(const Polygon &p) {
	ld res = 0;
	int n = p.size();
	REP(j, n) res += cross(p[j], p[(j + 1) % n]);
	return res / 2;
}

// ????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
	ld angle = 0;
	int n = poly.size();
	REP(i, n) {
		Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
		angle += arg((c - b) / (b - a));
	}
	return angle > eps;
}

// ??????????????????
//  0 => out
//  1 => on
//  2 => in
int is_in_polygon(const Polygon &poly, const  Point& p) {
	ld angle = 0;
	int n = poly.size();
	REP(i, n) {
		Point a = poly[i], b = poly[(i + 1) % n];
		if (isis_sp(Line(a, b), p)) return 1;
		angle += arg((b - p) / (a - p));
	}
	return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { OUT, ON, IN };
int convex_contains(const Polygon &P, const Point &p) {
	const int n = P.size();
	Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
	int a = 0, b = n;
	while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
		int c = (a + b) / 2;
		if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
			if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0) b = c;
			else                                                  a = c;
		}
		else {
			if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0) a = c;
			else                                                  b = c;
		}
	}
	b %= n;
	if (cross(P[a] - p, P[b] - p) < 0) return 0;
	if (cross(P[a] - p, P[b] - p) > 0) return 2;
	return 1;
}

// ??????
// ???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
	int n = ps.size();
	int k = 0;
	sort(ps.begin(), ps.end());
	Polygon ch(2 * n);
	for (int i = 0; i < n; ch[k++] = ps[i++])
		while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
		while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
	ch.resize(k - 1);
	return ch;
}



// ????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line& l) {
	int n = ps.size();
	Polygon Q;
	Polygon R;
	REP(i, n) {
		Point A = ps[i], B = ps[(i + 1) % n];
		Line m = Line(A, B);
		if (ccw(l.a, l.b, A) != -1) Q.push_back(A);
		if (ccw(l.a, l.b, A) != 1) R.push_back(A);
		if (ccw(l.a, l.b, A) * ccw(l.a, l.b, B) < 0 && isis_ll(l, m)) {
			Q.push_back(is_ll(l, m));
			R.push_back(is_ll(l, m));
		}
	}
	const vector<Polygon>polys{ Q,R };
	return polys;
}


/* ??¢??¬??????????????? */
void add_point(vector<Point> &ps, const Point p) {
	for (Point q : ps) if (abs(q - p) < eps) return;
	ps.push_back(p);
}

typedef int Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &g, const int from, const int to, const Weight weight) {
	g[from].push_back(Edge{ from, to, weight });
}

Graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
	int n = p.size(), m = s.size();
	Graph g(n);
	REP(i, m) {
		vector<pair<ld, int>> vec;
		REP(j, n) if (isis_sp(s[i], p[j]))
			vec.emplace_back(abs(s[i].a - p[j]), j);
		sort(ALL(vec));
		REP(j, vec.size() - 1) {
			int from = vec[j].second, to = vec[j + 1].second;
			add_edge(g, from, to, static_cast<Weight>(abs(p[from] - p[to])));
		}
	}
	return g;
}
Graph sennbunn_arrangement(const vector<Line>&s) {
	vector<Point>crss;
	for (int i = 0; i < static_cast<int>(s.size()); ++i) {
		for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
			if (isis_ss(s[i], s[j])) {
				crss.push_back(is_ll(s[i], s[j]));
			}
		}
	}
	for (int i = 0; i <static_cast<int>(s.size()); ++i) {
		crss.push_back(s[i][0]);
		crss.push_back(s[i][1]);
	}
	return segment_arrangement(s, crss);
}

//Graph circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
//	int n = p.size(), m = c.size();
//	Graph g(n);
//	REP(i, m) {
//		vector<pair<ld, int>> vec;
//		REP(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
//			vec.emplace_back(arg(c[i].p - p[j]), j);
//		sort(ALL(vec));
//		REP(j, vec.size() - 1) {
//			int from = vec[j].second, to = vec[j + 1].second;
//			ld angle = vec[j + 1].first - vec[j].first;
//			add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
//		}
//		if (vec.size() >= 2) {
//			int from = vec.back().second, to = vec.front().first;
//			ld angle = vec.front().first - vec.back().first;
//			add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
//		}
//	}
//	return g;
//}


/* ????????°?????? */

// ?????????????????¢?????¢??¬??????????????????????????????????????°???????????????
// ?????´?????????????¨?????????§????????´????????????????¨?????????§???????????????
// ?????° polygon ??????vector<int> ??§??¨?????????????§???¢???????????§?????????
// vector<int> ??§??¨????????? ????§???¢???i???????????????????????????????????????p????????????????????§?????????
vector<vector<int>> polygon;
vector<int> seg2p[1024][1024];

//Graph dual_graph(const vector<Line> &s, const vector<Point> &p) {
//	int N = p.size();
//	polygon.clear();
//	REP(i, 1024) REP(j, 1024) seg2p[i][j].clear();
//	vector<vector<tuple<ld, int, bool>>> tup(N);
//	REP(i, s.size()) {
//		int a = -1, b = -1;
//		REP(j, N) if (abs(s[i].a - p[j]) < eps) a = j;
//		REP(j, N) if (abs(s[i].b - p[j]) < eps) b = j;
//		assert(a >= 0 && b >= 0);
//		tup[a].emplace_back(arg(s[i].b - s[i].a), b, false);
//		tup[b].emplace_back(arg(s[i].a - s[i].b), a, false);
//	}
//	REP(i, N) sort(ALL(tup[i]));
//	REP(i, N) {
//		REP(j, tup[i].size()) {
//			ld angle; int pos = j, from = i, to; bool flag;
//			tie(angle, to, flag) = tup[i][j];
//			if (flag) continue;
//			vector<int> ps;
//			while (!flag) {
//				ps.push_back(from);
//				get<2>(tup[from][pos]) = true;
//				seg2p[from][to].push_back(polygon.size());
//				seg2p[to][from].push_back(polygon.size());
//				angle += pi + eps;
//				if (angle > pi) angle -= 2 * pi;
//				auto it = lower_bound(ALL(tup[to]), make_tuple(angle, 0, false));
//				if (it == tup[to].end()) it = tup[to].begin();
//				from = to; tie(angle, to, flag) = *it;
//				pos = it - tup[from].begin();
//			}
//			polygon.push_back(ps);
//		}
//	}
//	Graph g(polygon.size());
//	REP(i, N) REP(j, i) {
//		if (seg2p[i][j].size() == 2) {
//			int from = seg2p[i][j][0], to = seg2p[i][j][1];
//			g[from].push_back(Edge{ from, to });
//			g[to].push_back(Edge{ to, from });
//		}
//	}
//	return g;
//}

struct flo {
	Point p;
	ld the;
};
bool check(const flo&f, const Point p,const ld len,const ld theta) {
	const ld dis = abs(f.p - p);
	if (dis-eps > len) {
		return false;
	}
	else {
		ld kaku = atan2(p.imag() - f.p.imag(), p.real() - f.p.real());
		if (kaku < 0)kaku += 2*pi;
		ld sa = abs(kaku - theta);
		sa = min(sa, 2 * pi - sa);
		if (sa < f.the / 2)return true;
		else return false;
	}
}
int main() {
	while (1) {
		vector<Point>houses;
		int H, R; cin >> H >> R;
		if (!H)break;
		for (int i = 0; i < H; ++i) {
			int x, y; cin >> x >> y;
			houses.emplace_back(x, y);
		}
		int U, M, S;ld du, dm, ds;  cin >> U >> M >> S >> du >> dm >> ds;
		du *= dtop;
		dm *= dtop;
		ds *= dtop;
		vector<flo>flowers;
		for (int i = 0; i < U; ++i) {
			int x, y; cin >> x >> y;
			flowers.push_back(flo{ Point(x,y),du });
		}
		for (int i = 0; i < M; ++i) {
			int x, y; cin >> x >> y;
			flowers.push_back(flo{ Point(x,y),dm });
		}
		for (int i = 0; i < S; ++i) {
			int x, y; cin >> x >> y;
			flowers.push_back(flo{ Point(x,y),ds });
		}
		flo myflower{ Point(0,0),du };
		int ans = 0;
		vector<int>nums(H);
		for (int i = 0; i < R; ++i) {
			ld w, a; cin >> a >> w;
			a *= dtop;
			for (int h = 0; h < H; ++h) {
				Point p(houses[h]);
				if (check(myflower, p, w, a)) {

					bool aok = true;
					for (auto f : flowers) {
						if (check(f, p, w, a)) {
							aok = false;
							break;
						}
					}
					if (aok) {
						nums[h]++;
					}
				}
			}
		}
		int amax = *max_element(nums.begin(), nums.end());
		if (amax) {
			vector<int>anss;
			for (int i = 0; i < H; ++i) {
				if (amax == nums[i]) {
					anss.push_back(i+1);
				}
			}
			for (int i = 0; i < anss.size(); ++i) {
				cout << anss[i];
				if (i != anss.size() - 1)cout << " ";
				else cout << endl;
			}
		}
		else {
			cout << "NA" << endl;
		}
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 27868
final_rank: 19

code_snippet: #include<bits/stdc++.h>
using namespace std;

typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

typedef complex<double>P;

const double EPS=1e-6;
const double PI=acos(-1);

const int COUNTER_CLOCKWISE=1;
const int CLOCKWISE=-1;
const int ONLINE_BACK=2;
const int ONLINE_FRONT=-2;
const int ON_SEGMENT=0;

inline double dot(const P &a, const P &b){return (conj(a) * b).real();}
inline double cross(const P &a, const P &b){return (conj(a) * b).imag();}

double toRad(double a){return a/180.0*PI;}
double toDeg(double a){return a*180.0/PI;}
P rotate(P p,double d){
    return P(p.real()*cos(d)-p.imag()*sin(d),p.real()*sin(d)+p.imag()*cos(d));
}

P getP(){
    double x,y;
    scanf("%lf%lf",&x,&y);
    return P(x,y);
}

int ccw(P p0,P p1,P p2){
    P a=p1-p0;
    P b=p2-p0;
    if(cross(a,b)>EPS)return COUNTER_CLOCKWISE;
    if(cross(a,b)<-EPS)return CLOCKWISE;
    if(dot(a,b)<-EPS)return ONLINE_BACK;
    if(norm(a)<norm(b))return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool ok(P from,P to,double w,double a,double d){
    if(abs(to-from)>a)return false;

    d=toRad(d);
    w=toRad(w);

    double left=w+d/2;
    double right=w-d/2;
    P vh=to-from;
    P vl=a*P(cos(left),sin(left));
    P vr=a*P(cos(right),sin(right));

    return (cross(vr,vh)>-EPS)&&(cross(vh,vl)>-EPS);
}

int H,R;
vector<P>h;

int U,M,S;
double du,dm,ds;
vector<P>u,m,s;
void solve(){
    h.resize(H);
    rep(i,H)h[i]=getP();

    scanf("%d%d%d",&U,&M,&S);
    scanf("%lf%lf%lf",&du,&dm,&ds);

    u.resize(U);
    m.resize(M);
    s.resize(S);
    rep(i,U)u[i]=getP();
    rep(i,M)m[i]=getP();
    rep(i,S)s[i]=getP();

    int cnt[100]={0};

    while(R--){
        double w,a;
        scanf("%lf%lf",&w,&a);
        rep(i,H){
            bool f=false;
            if(ok(P(0,0),h[i],w,a,du))f=true;
            rep(j,U)if(ok(u[j],h[i],w,a,du))f=false;
            rep(j,M)if(ok(m[j],h[i],w,a,dm))f=false;
            rep(j,S)if(ok(s[j],h[i],w,a,ds))f=false;
            if(f)cnt[i]++;
        }
    }

    int ma=*max_element(cnt,cnt+H);
    if(ma==0){
        puts("NA");
        return;
    }

    bool f=false;
    rep(i,H){
        if(cnt[i]!=ma)continue;
        if(f)printf(" ");
        else f=true;
        printf("%d",i+1);
    }
    puts("");
}

int main(){
    while(scanf("%d%d",&H,&R),H||R)solve();
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1260
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, double> Tree;

int H;
Point home[100];

int U, M, S, du, dm, ds;
Tree tree[31];

int R;
int w[100], a[100];

double toRad(double theta)
{
	return theta / 180 * acos(-1);
}

double cross(Point a, Point b)
{
	return a.real() * b.imag() - a.imag() * b.real();
}

bool contains(Tree tree, Point home, double dir, double len)
{
	if (abs(home - tree.first) > len) return false;
	double left = dir + tree.second / 2;
	double right = dir - tree.second / 2;
	Point vh = home - tree.first;
	Point vl = polar(len, left);
	Point vr = polar(len, right);
	return (cross(vr, vh) > -1e-6) && (cross(vh, vl) > -1e-6);
}

void solve()
{
	// day, home
	static int reach[100][100];
	fill_n(*reach, 100 * 100, 0);
	
	for (int i = 0; i < R; i++){
		for (int j = 0; j < H; j++){
			for (int k = 0; k <= U + M + S; k++){
				if (contains(tree[k], home[j], toRad(w[i]), a[i])){
					reach[i][j] |= 1 << k;
				}
			}
		}
	}
	
	static int cnt[100];
	fill_n(cnt, 100, 0);
	
	int maxi = 0;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < R; j++){
			cnt[i] += (reach[j][i] == 1);
			maxi = max(maxi, cnt[i]);
		}
	}
	
	if (maxi == 0) puts("NA");
	else {
		bool f = false;
		for (int i = 0; i < H; i++){
			if (cnt[i] == maxi){
				if (f) printf(" ");
				f = true;
				printf("%d", i + 1);
			}
		}
		puts("");
	}
}

int main()
{
	while (scanf("%d %d", &H, &R), H){
		for (int i = 0; i < H; i++){
			int x, y;
			scanf("%d %d", &x, &y);
			home[i] = Point(x, y);
		}
		
		scanf("%d %d %d", &U, &M, &S);
		scanf("%d %d %d", &du, &dm, &ds);
		tree[0] = Tree(Point(0, 0), toRad(du));
		for (int i = 0; i < U + M + S; i++){
			int x, y, d;
			scanf("%d %d", &x, &y);
			if (i < U) d = du;
			else if (i < U + M) d = dm;
			else d = ds;
			tree[i + 1] = Tree(Point(x, y), toRad(d));
		}
		
		for (int i = 0; i < R; i++){
			scanf("%d %d", &w[i], &a[i]);
		}
		
		solve();
	}
	
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1256
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

template<class T>
struct Pt {
  T x,y;
  Pt(T x=T(), T y=T()) :x(x),y(y) {}
  void in() {ll _x, _y; input(_x,_y); x=_x; y=_y; }
  bool operator<(const Pt &p) const { return x!=p.x?x<p.x:y<p.y; }
  bool operator==(const Pt &p) const { return x==p.x&&y==p.y; }
  Pt operator+=(const Pt &p) { x+=p.x, y+=p.y; return *this; }
  Pt operator-=(const Pt &p) { x-=p.x, y-=p.y; return *this; }
  Pt operator*=(const Pt &p) { T t=x;x=x*p.x-y*p.y,y=t*p.y+y*p.x; return *this;}
  Pt operator*=(const T &v) { x*=v; y*=v; return *this;}
  friend ostream& operator<<(ostream& os, const Pt &p) {return os<<'('<<p.x<<','<<p.y<<')';}
  friend istream& operator>>(istream& is, Pt &p) {return is>>p.x>>p.y;}

  Pt operator+(const Pt &p) const { return Pt(*this)+=p; }
  Pt operator-(const Pt &p) const { return Pt(*this)-=p; }
  Pt operator*(const Pt &p) const { return Pt(*this)*=p; }
  Pt operator*(const T &v) const { return Pt(*this)*=v; }
  friend Pt operator*(const T &v, const Pt &p) { return p*v; }
  bool operator!=(const Pt &p) const { return !(*this == p); }

  T abs() const { return hypot(x,y); }
  T norm() const { return x*x+y*y; }
  T arg() const { return atan2(y,x); }
  T dot(const Pt &p) const { return x*p.x+y*p.y; }
  T det(const Pt &p) const { return x*p.y-y*p.x; }
  friend T abs(const Pt &p) { return p.abs(); }
  friend T norm(const Pt &p) { return p.norm(); }
  friend T arg(const Pt &p) { return p.arg(); }
  friend T dot(const Pt &p, const Pt &q) { return p.dot(q); }
  friend T det(const Pt &p, const Pt &q) { return p.det(q); }
};

int sig(double r) {return r<-EPS?-1:r>EPS?1:0;}
int sig(ll r) {return r<0?-1:r>0?1:0;}
bool eq(double a, double b) {return sig(a-b)==0;}
bool eq(ll a, ll b) {return a==b;}
Pt<double> pol(double len, double ang) { return Pt<double>(cos(ang),sin(ang)) * len; }

typedef Pt<double> P;

double angle(const P &a, const P &b) {
  double ret = arg(b)-arg(a);
  if (!sig(ret)||!sig(ret-2*PI)) return 0;
  return ret>0 ? ret : ret + 2*PI;
}

template<typename _T>
struct Ci {
  typedef _T T;
  Pt<T> p; T r;
  Ci(const Pt<T> &p, T r) : p(p), r(r) { }
};
typedef Ci<double> C;

// 扇型
struct CS : C {
  P p1, p2;
  CS(const P &p, const P &p1, const P &p2):
    C(p,abs(p1)),p1(p1),p2(p2) {}
};

bool intersectCSP(const CS &cs, const P &p) {
  return angle(cs.p1, p-cs.p) < angle(cs.p1, cs.p2)+EPS &&
    abs(cs.p-p) <= cs.r+EPS;
}

struct Tree {
  P p;
  double d;
  Tree(const P &p, double d) : p(p), d(d) {}
  CS getCS(double w, double a) {
    return CS(p, pol(a, w - d/2), pol(a, w + d/2));
  }
};

int main() {
  int H, R;
  while(input(H,R), H || R) {
    vector<P> home(H);
    REP(i,H) cin >> home[i];
    int U,M,S;
    input(U,M,S);
    double du,dm,ds;
    cin>>du>>dm>>ds;
    du = du / 180 * PI;
    dm = dm / 180 * PI;
    ds = ds / 180 * PI;
    vector<Tree> tree;
    REP(i,U) {
      P p; cin >> p;
      tree.push_back(Tree(p,du));
    }
    REP(i,M) {
      P p; cin >> p;
      tree.push_back(Tree(p,dm));
    }
    REP(i,S) {
      P p; cin >> p;
      tree.push_back(Tree(p,ds));
    }
    vector<int> numday(H);

    Tree mine(P(), du);
    REP(i,R) {
      double w,a;
      cin >> w >> a;
      w = w / 180 * PI;
      CS mycs = mine.getCS(w,a);
      REP(i,home.size()) {
        const P& h = home[i];
        bool ok = intersectCSP(mycs, h);
        if (!ok) continue;
        for (auto &t : tree) {
          CS cs = t.getCS(w,a);
          ok &= !intersectCSP(cs, h);
        }
        if (ok)
          numday[i]++;
      }
    }
    int mx = *max_element(ALL(numday));
    if (mx == 0) puts("NA");
    else {
      bool f = 0;
      REP(i,H) {
        if (numday[i] == mx) {
          if (f) printf(" ");
          printf("%d", i+1);
          f = 1;
        }
      }
      cout << endl;
    }
  }
}
accuracy: 1
time_ms: 20
memory_kb: 1340
final_rank: 8

code_snippet: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <cstring>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;
const double EPS = 1e-8;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

struct P{
    P(){}
    P(double _r, double _i):r(_r), i(_i){}
    void real(const double& v){r = v;}
    void imag(const double& v){i = v;}
    double r, i;
};

double real(const P& p){return p.r;}
double imag(const P& p){return p.i;}
double norm(const P& p){double r = real(p), i = imag(p); return r * r + i * i;}
double dist(const P& p){return std::sqrt(norm(p));}

P operator+(const P& lhs, const P& rhs){
    return P(real(lhs)+real(rhs), imag(lhs)+imag(rhs));
}
P operator-(const P& lhs, const P& rhs){
    return P(real(lhs)-real(rhs), imag(lhs)-imag(rhs));
}
P operator-(const P& p){
    return P(-real(p), -imag(p));
}

double cross(const P& lhs, const P& rhs){
    return real(lhs)*imag(rhs) - imag(lhs)*real(rhs);
}

double dot(const P& lhs, const P& rhs){
    return real(lhs)*real(rhs) + imag(lhs)*imag(rhs);
}

int H, R, U, M, S;
double du, dm, ds;
P hs[100], us[10], ms[10], ss[10];

bool can(P home, P flower, double d, P wind){
    if(dist(home-flower) > imag(wind)){return false;}
    P center;
    center.real(imag(wind) * std::cos(M_PI / 180.0f * real(wind)));
    center.imag(imag(wind) * std::sin(M_PI / 180.0f * real(wind)));
    // {
    //     P p = home-flower;
    //     printf("%f, %f\n", real(center), imag(center));
    // }
    double s = cross(center, home-flower) / dist(center) / dist(home-flower),
        c = dot(center, home-flower) / dist(center) / dist(home-flower);
    // printf("%f, %f\n", c, s);
    if((c < 0.0f && d > 90.0f || c > 0.0f) && std::abs(s) < std::sin(M_PI / 360.0f * d) + EPS){
        return true;
    }
    return false;
}

int main(){
    while(std::cin >> H >> R, H || R){
        REP(i, H){
            double x, y;
            std::cin >> x >> y;

            hs[i].real(x); hs[i].imag(y);
        }

        std::cin >> U >> M >> S >> du >> dm >> ds;
        REP(i, U){
            double x, y;
            std::cin >> x >> y;

            us[i].real(x); us[i].imag(y);
        }
        REP(i, M){
            double x, y;
            std::cin >> x >> y;

            ms[i].real(x); ms[i].imag(y);
        }
        REP(i, S){
            double x, y;
            std::cin >> x >> y;

            ss[i].real(x); ss[i].imag(y);
        }

        P origin(0.0f, 0.0f);
        int counter[100];
        memset(counter, 0, sizeof(counter));
        REP(i, R){
            double x, y;
            std::cin >> x >> y;
            P wind(x, y);

            REP(k, H){
                bool f = can(hs[k], origin, du, wind),
                    g = true;

                REP(j, U){
                    g = g && !can(hs[k], us[j], du, wind);
                }
                REP(j, M){
                    g = g && !can(hs[k], ms[j], dm, wind);
                }
                REP(j, S){
                    g = g && !can(hs[k], ss[j], ds, wind);
                }

                if(f && g){counter[k] += 1;}
            }
        }

        int maxDays = 0;
        REP(i, H){
            maxDays = std::max(maxDays, counter[i]);
        }

        if(maxDays == 0){
            puts("NA");
        }else{
            std::vector<int> indices;
            REP(i, H){
                if(counter[i] == maxDays){indices.push_back(i+1);}
            }

            REP(i, (int)indices.size()){
                if(i == (int)indices.size() - 1){printf("%d\n", indices[i]);}
                else{printf("%d ", indices[i]);}
            }
        }
    }
}
accuracy: 1
time_ms: 10
memory_kb: 1264
final_rank: 4

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

const double PI = 3.14159265358979;

class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};

class Wind {
public:
    double w, a;
};

bool include(double angle, double low, double high) {
    if(low < 0.0 && 2.0 * PI + low <= angle) return true;
    if(high >= 2.0 * PI && angle <= high - 2.0 * PI) return true;
    return low <= angle && angle <= high;
}

bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0.0) angle = 2.0 * PI + angle;
        if(dist <= wind.a && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}

double toRadian(double d) {
    return d * PI / 180.0;
}

int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;

        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;

        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);

        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;

        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);

        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;

        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);

                if(!ok || ng) continue;

                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }

        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}
accuracy: 1
time_ms: 30
memory_kb: 1336
final_rank: 12

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

const double PI = 3.14159265358979;

class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};

class Wind {
public:
    double w, a;
};

bool include(double angle, double low, double high) {
    if(low < 0.0 && low + 2.0 * PI <= angle) return true;
    if(high >= 2.0 * PI && angle <= high - 2.0 * PI) return true;
    return low <= angle && angle <= high;
}

bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0.0) angle = angle + 2.0 * PI;
        if(dist <= wind.a && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}

double toRadian(double d) {
    return d * PI / 180.0;
}

int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;

        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;

        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);

        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;

        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);

        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;

        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);

                if(!ok || ng) continue;

                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }

        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}
accuracy: 1
time_ms: 30
memory_kb: 1332
final_rank: 11

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

const double PI = 3.14159265358979;

class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};

class Wind {
public:
    double w, a;
};

bool include(double angle, double low, double high) {
    if(low < 0.0) {
        double l = low + 2.0 * PI;
        if(l <= angle) return true;
    }
    if(high > 2.0 * PI) {
        double h = high - 2.0 * PI;
        if(angle <= h) return true;
    }
    return low <= angle && angle <= high;
}

bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0.0) angle = angle + 2.0 * PI;
        if(dist <= wind.a && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}

double toRadian(double d) {
    return d * PI / 180.0;
}

int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;

        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;

        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);

        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;

        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);

        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;

        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);

                if(!ok || ng) continue;

                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }

        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}
accuracy: 1
time_ms: 30
memory_kb: 1336
final_rank: 12

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
using namespace std;
 
const double PI = 3.14159265358979;
 
class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};
 
class Wind {
public:
    double w, a;
};
 
bool include(double angle, double low, double high) {
    if(low < 0.0) {
        double l = low + 2.0 * PI;
        if(l <= angle) return true;
    }
    if(high > 2.0 * PI) {
        double h = high - 2.0 * PI;
        if(angle <= h) return true;
    }
    return low <= angle && angle <= high;
}
 
bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0.0) angle = angle + 2.0 * PI;
        if(dist <= wind.a && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}
 
double toRadian(double d) {
    return d * PI / 180.0;
}
 
int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;
 
        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;
 
        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);
 
        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;
 
        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);
 
        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;
 
        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);
 
                if(!ok || ng) continue;
 
                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }
 
        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}
accuracy: 1
time_ms: 30
memory_kb: 1336
final_rank: 12

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
using namespace std;
 
const double PI = 3.14159265358979;
const double EPS = 1e-9;
 
class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};
 
class Wind {
public:
    double w, a;
};
 
bool include(double angle, double low, double high) {
    if(low < 0 + EPS) {
        double l = low + 2.0 * PI;
        if(l <= angle + EPS) return true;
    }
    if(high > 2.0 * PI + EPS) {
        double h = high - 2.0 * PI;
        if(angle <= h + EPS) return true;
    }
    return low <= angle + EPS && angle <= high + EPS;
}
 
bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0) angle = angle + 2 * PI;
        if(dist <= wind.a + EPS && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}
 
double toRadian(double d) {
    return d * PI / 180.0;
}
 
int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;
 
        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;
 
        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);
 
        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;
 
        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);
 
        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;
 
        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);
 
                if(!ok || ng) continue;
 
                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }
 
        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}
accuracy: 1
time_ms: 30
memory_kb: 1336
final_rank: 12

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
using namespace std;

const double PI = 3.14159265358979;
const double EPS = 1e-9;

class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};

class Wind {
public:
    double w, a;
};

bool include(double angle, double low, double high) {
    if(low < 0 + EPS) {
        double l = low + 2.0 * PI;
        if(l <= angle + EPS) return true;
    }
    if(high > 2.0 * PI + EPS) {
        double h = high - 2.0 * PI;
        if(angle <= h + EPS) return true;
    }
    return low <= angle + EPS && angle <= high + EPS;
}

bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0) angle = angle + 2 * PI;
        if(dist <= wind.a + EPS && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}

double toRadian(double d) {
    return d * PI / 180.0;
}

int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;

        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;

        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);

        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;

        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);

        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;

        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);

                if(!ok || ng) continue;

                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }

        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}
accuracy: 1
time_ms: 30
memory_kb: 1340
final_rank: 16

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
using namespace std;

const double PI = 3.14159265358979;
const double EPS = 1e-9;

class Point {
public:
    double x, y;
    Point(double x = 0.0, double y = 0.0) :x(x), y(y) {}
};

class Wind {
public:
    double w, a;
};

bool include(double angle, double low, double high) {
    if(low < 0 + EPS) {
        double l = low + 2.0 * PI;
        if(l <= angle + EPS) return true;
    }
    if(high > 2.0 * PI + EPS) {
        double h = high - 2.0 * PI;
        if(angle <= h + EPS) return true;
    }
    return low <= angle + EPS && angle <= high + EPS;
}

bool savor(const Point &home, const Wind &wind, const vector<Point> &blossom, double d) {
//     cout << "home: " << home.x << ", " << home.y << endl;
//     cout << "blossom" << endl; for(const auto &i: blossom) cout << "  " << i.x << "," << i.y; cout << endl;
//     cout << "d: " << d << endl;
//     cout << "wind: " << wind.w << ", " << wind.a << endl;
//     cout << endl;
    d /= 2.0;
    for(const auto &b: blossom) {
        Point dif(home.x - b.x, home.y - b.y);
        double angle = atan2(dif.y, dif.x);
        double dist = hypot(dif.y, dif.x);
        if(angle < 0) angle = 2 * PI + angle;
//         cout<<"angle: "<<angle<<endl;
//         cout<<"wind.w +- d: "<<wind.w - d<<" - "<<wind.w + d<<endl;
//         cout<<"dist: "<<dist<<endl;
        if(dist <= wind.a + EPS && include(angle, wind.w - d, wind.w + d)) return true;
    }
    return false;
}

double toRadian(double d) {
    return d * PI / 180.0;
}

int main() {
    int H, R;
    while(cin >> H >> R, H | R) {
        vector<Point> home(H);
        for(auto &i: home) cin >> i.x >> i.y;

        int U, M, S;
        double du, dm, ds;
        cin >> U >> M >> S >> du >> dm >> ds;

        du = toRadian(du);
        dm = toRadian(dm);
        ds = toRadian(ds);

        vector<Point> plum(U), peach(M), cherry(S);
        for(auto &i: plum) cin >> i.x >> i.y;
        for(auto &i: peach) cin >> i.x >> i.y;
        for(auto &i: cherry) cin >> i.x >> i.y;

        vector<Wind> wind(R);
        for(auto &i: wind) cin >> i.w >> i.a;
        for(auto &i: wind) i.w = toRadian(i.w);

        // test
//         cout << savor(home[5], wind[0], peach, dm) << endl;
//         return 0;

        // solve
        vector<int> number(H, 0);
        int maxNumber = 0;

        for(int i = 0; i < H; ++i) {
            for(int day = 0; day < R; ++day) {
                bool ok = savor(home[i], wind[day], {Point(0.0, 0.0)}, du);
                bool ng = false;
                ng |= savor(home[i], wind[day], plum, du);
                ng |= savor(home[i], wind[day], peach, dm);
                ng |= savor(home[i], wind[day], cherry, ds);

//                 cout<<"day"<<day<<endl;
//                 cout<<savor(home[i], wind[day], plum, du)<<" "<<savor(home[i], wind[day], peach, du)<<" "<<savor(home[i], wind[day], cherry, du)<<endl;

                if(!ok || ng) continue;

                ++number[i];
                maxNumber = max(maxNumber, number[i]);
            }
        }

//         for(const auto &i: number) cout<<" "<<i;cout<<endl;

        if(maxNumber) {
            bool first = true;
            for(int i = 0; i < H; ++i) if(number[i] == maxNumber) {
                if(!first) cout << " ";
                first = false;
                cout << i + 1;
            }
            cout << endl;
        } else {
            cout << "NA" << endl;
        }

//         return 0;
    }
}
accuracy: 1
time_ms: 20
memory_kb: 1336
final_rank: 7

code_snippet: #include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-7)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;

const int IINF = INT_MAX;

class Point{
public:
  double x,y;

  Point(double x = -IINF,double y = -IINF): x(x),y(y){}

  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}

};

double dot(Point a,Point b){ return a.x*b.x + a.y*b.y; }

double cross(Point a,Point b){ return a.x*b.y - a.y*b.x; }

double norm(Point a){ return a.x*a.x+a.y*a.y; }

double abs(Point a){ return sqrt(norm(a)); }

Point rotate(Point a,double rad){ return Point(cos(rad)*a.x - sin(rad)*a.y,sin(rad)*a.x + cos(rad)*a.y); }

double toRad(double agl){ return agl*M_PI/180.0; }

int ccw(Point p0,Point p1,Point p2){
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS)return CLOCKWISE;
  if(dot(a,b) < -EPS)return ONLINE_BACK;
  if(norm(a) < norm(b))return ONLINE_FRONT;
  return ON_SEGMENT;
}

const int MAX_N = 110;
int N,M,Ume,Momo,SakuraHappyInnovation,counter[MAX_N],limit[3];
Point ps[MAX_N],p[3][20];
double d[3],w[110],a[110];

bool LT(double A,double B)  { return !equals(A,B) && A < B; }
bool LTE(double A,double B) { return  equals(A,B) || A < B; }

bool inside(Point h,Point t,double ta,double tw,double td){
  double rad_w = toRad(tw), rad_d = toRad(td/2.0);
  Point tmp = Point(ta*cos(rad_w),ta*sin(rad_w));
  Point alpha = rotate(tmp,-rad_d) + t;
  Point beta  = rotate(tmp,rad_d)  + t;
  int res_ccw = ccw(t,alpha,h);
  bool res1 = ( res_ccw != CLOCKWISE );
  res_ccw = ccw(t,beta,h);
  bool res2 = ( res_ccw != COUNTER_CLOCKWISE );
  double dist = abs(h-t);
  bool res3 = LTE(dist,ta);
  return res1 && res2 && res3;
}

inline void compute(){
  rep(i,N) counter[i] = 0;
  rep(_,M){
    rep(i,N){
      bool failed = false;
      if( inside(ps[i],Point(0,0),a[_],w[_],d[0]) ) {
        rep(j,3) if( !failed ) rep(k,limit[j]) failed |= inside(ps[i],p[j][k],a[_],w[_],d[j]);
      } else failed = true;
      if( !failed ) ++counter[i];
    }
  }
  int maxi = -1;
  rep(i,N) if( counter[i] != 0 ) maxi = max(maxi,counter[i]);
  if( maxi == -1 ) puts("NA");
  else {
    bool first = true;
    rep(i,N) if( counter[i] == maxi ){
      if( !first ) printf(" "); first = false;
      printf("%d",i+1);
    }
    puts("");
  }
}

int main(){
  while( scanf("%d %d",&N,&M), N|M ){
    rep(i,N) scanf("%lf %lf",&ps[i].x,&ps[i].y);
    scanf("%d %d %d %lf %lf %lf",&Ume,&Momo,&SakuraHappyInnovation,d,d+1,d+2);
    limit[0] = Ume, limit[1] = Momo, limit[2] = SakuraHappyInnovation;
    rep(i,Ume) scanf("%lf %lf",&p[0][i].x,&p[0][i].y);
    rep(i,Momo) scanf("%lf %lf",&p[1][i].x,&p[1][i].y);
    rep(i,SakuraHappyInnovation) scanf("%lf %lf",&p[2][i].x,&p[2][i].y);
    rep(i,M) scanf("%lf %lf",w+i,a+i);
    compute();
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1248
final_rank: 1

code_snippet: //自分の梅は任意の地点でかおるとする。→間違い。
//EPSはつけない。
//扇形と家は接しないので、距離はsqrtで求めた。

#include<iostream>
#include<cmath>
#include<vector>
#define rep(i,n) for(i = 0;i < n;i++)
#define PI 3.14159265358979
using namespace std;

typedef pair<double,double> P;

int H,R;				//家数,日数
int hx[100],hy[100];	//家の座標
int U,M,S;				//梅、桃、桜の数
int du,dm,ds;			//梅、桃、桜の扇形の中心角
int ux[100],uy[100];	//梅の座標
int mx[100],my[100];	//桃の座標
int sx[100],sy[100];	//桜の座標
int w[100],a[100];		//扇形の方向(角度),風の強さ

//半径,角度の順で格納し、返す
//rotateは角度補正( 補正 = rotate*360 )
P POLAR( int treex,int treey,int housex,int housey,int rotate )
{
	P ans;
	ans.first = (housex-treex)*(housex-treex) + (housey-treey)*(housey-treey);
	ans.first = sqrt( ans.first );
	ans.second = atan2( (double)housey - treey, (double)housex - treex ) * 180 / PI;
	ans.second += 360*rotate;
	return ans;
}

int main()
{
	int i,j,k,l;
	while( cin >> H >> R )
	{
		int day[100] = {0};		//i番目の家において、他の木の香りが届かなかった日数

		if( H == 0 && R == 0 )
			break;
		rep(i,H)
			cin >> hx[i] >> hy[i];
		cin >> U >> M >> S >> du >> dm >> ds;
		rep(i,U)
			cin >> ux[i] >> uy[i];
		rep(i,M)
			cin >> mx[i] >> my[i];
		rep(i,S)
			cin >> sx[i] >> sy[i];
		rep(i,R)
			cin >> w[i] >> a[i];
		//ここから探索
		rep(i,R){
			rep(j,H){
				rep(k,U){
					rep(l,3){
						P t = POLAR( ux[k],uy[k],hx[j],hy[j],l-1 );
						//判定
						if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= (double)du/2.0 )
							break;
					}
					if(l < 3)
						break;
				}
				if(k < U)
					continue;
				rep(k,M){
					rep(l,3){
						P t = POLAR( mx[k],my[k],hx[j],hy[j],l-1 );
						//判定
						if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= (double)dm/2.0 )
							break;
					}
					if(l < 3)
						break;
				}
				if(k < M)
					continue;
				rep(k,S){
					rep(l,3){
						P t = POLAR( sx[k],sy[k],hx[j],hy[j],l-1 );
						//判定
						if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= (double)ds/2.0 )
							break;
					}
					if(l < 3)
						break;
				}
				if(k < S)
					continue;

				//私の梅の香りは届くのか！！
				rep(l,3){
					P t = POLAR( 0,0,hx[j],hy[j],l-1 );
					//判定
					if( t.first <= a[i] && fabs( (double)w[i] - t.second ) <= du/2.0 )
						break;
				}
				if( l < 3 )
					day[j]++;
			}
		}
		int maxday = 0;
		rep(i,H){
			maxday = max( maxday,day[i] );
		}
		if( maxday == 0 ){
			cout << "NA" << endl;
			continue;
		}

		int lasthouse = 0; 
		rep(i,H){
			if( day[i] == maxday ){
				lasthouse = i;
			}
		}
		rep(i,H){
			if( day[i] == maxday ){
				cout << i+1;
				if( i < lasthouse )
					cout << ' ';
				else
					cout << endl;
			}
		}
	}
	return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 1256
final_rank: 18

code_snippet: #include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;
typedef complex<double> P;

const double PI = acos(-1);
const double EPS = 1e-9;
bool hit(P p,double a,double b,double r){
	if( abs(p) > r + EPS ) return false;
	double deg = atan2(p.imag(),p.real());
	if( a <= deg && deg <= b ) return true;
	if( a <= deg+2*PI && deg+2*PI <= b ) return true;
	if( a <= deg-2*PI && deg-2*PI <= b ) return true;
	return false;
}
int main(){
	int H,R;
	while(cin >> H >> R && H){
		P home[100];
		for(int i = 0 ; i < H ; i++) cin >> home[i].real() >> home[i].imag();
		int U,M,S;
		double du,dm,ds;
		cin >> U >> M >> S >> du >> dm >> ds;
		du = du / 180.*PI;
		dm = dm / 180.*PI;
		ds = ds / 180.*PI;
		du /= 2;
		dm /= 2;
		ds /= 2;
		vector< pair<P,double> > flower;
		for(int i = 0 ; i < U+M+S ; i++){	
			P p; cin >> p.real() >> p.imag();
			flower.push_back(make_pair(p,(i<U?du:i<U+M?dm:ds)));
		}
		int answer[110] = {};
		for(int i = 0 ; i < R ; i++){
			double w,r;
			cin >> w >> r;
			w = w / 180. * PI;
			for(int j = 0 ; j < H ; j++){
				int ok = hit(home[j],w-du,w+du,r);
				//cout << w-du << " " << w+du << endl;
				for(int k = 0 ; k < U+M+S ; k++){
					ok &= !hit(home[j]-flower[k].first,w-flower[k].second,w+flower[k].second,r);
				}
				answer[j] += ok;
			}
		}
		int maximum = *max_element(answer,answer+H);
		int fst = 1;
		if( maximum == 0 ){ cout << "NA" << endl; goto exit; }

		for(int i = 0 ; i < H ; i++)
			if( maximum == answer[i] ){
				if( fst == 0 ) cout << " ";
				cout << i+1;
				fst = 0;
			}
		cout << endl;
		exit:;
	}
	
	
	
	
}
accuracy: 1
time_ms: 10
memory_kb: 1312
final_rank: 5