Submission #241817


Source Code Expand

Copy
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 1000000000
#define EPS 1e-10

#define MAX_N 5000

int A, B;
int N;
int C[MAX_N];
int D[MAX_N];

int main() {

	cin >> A >> B;
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> C[i] >> D[i];

	}

	for (int i = 0; i < N; i++){

		bool flag1 = true;
		bool flag2 = true;

		double ub, lb;
		ub = max((double)C[i], (double)D[i]);
		lb = 0;

		while (ub - lb > EPS){
			double mid = (ub + lb) / 2;
			double c = (double)C[i] - mid;
			double d = (double)D[i] - mid;
			if (c*c + d * d >= B*B)
				lb = mid;
			else
				ub = mid;
		}

		if (lb * lb * 2 < A*A)
			flag1 = false;

		if (!flag1){
			ub = max((double)C[i], (double)D[i]);
			lb = 0;
			while (ub - lb > EPS){
				double mid = (ub + lb) / 2;
				double c = (double)C[i] - mid;
				double d = (double)D[i] - mid;
				if (c*c + d * d >= A*A)
					lb = mid;
				else
					ub = mid;
			}

			if (lb * lb * 2 < B*B)
				flag2 = false;

		}

		if (flag1 || flag2)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

	}

	return 0;
}

Submission Info

Submission Time
Task B - 高橋君と禁断の書
User taketake0609
Language C++ (G++ 4.6.4)
Score 0
Code Size 1595 Byte
Status
Exec Time 48 ms
Memory 932 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0-sample-01.txt
All 0 / 100 subtask0-sample-01.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt, subtask1-17.txt, subtask1-18.txt, subtask1-19.txt, subtask1-20.txt, subtask1-21.txt, subtask1-22.txt, subtask1-23.txt, subtask1-24.txt, subtask1-25.txt, subtask1-26.txt, subtask1-27.txt, subtask1-28.txt, subtask1-29.txt, subtask1-30.txt
Case Name Status Exec Time Memory
subtask0-sample-01.txt 24 ms 752 KB
subtask1-01.txt 23 ms 920 KB
subtask1-02.txt 24 ms 924 KB
subtask1-03.txt 29 ms 748 KB
subtask1-04.txt 31 ms 800 KB
subtask1-05.txt 35 ms 816 KB
subtask1-06.txt 41 ms 800 KB
subtask1-07.txt 40 ms 928 KB
subtask1-08.txt 41 ms 920 KB
subtask1-09.txt 44 ms 924 KB
subtask1-10.txt 45 ms 928 KB
subtask1-11.txt 42 ms 792 KB
subtask1-12.txt 44 ms 928 KB
subtask1-13.txt 43 ms 796 KB
subtask1-14.txt 44 ms 924 KB
subtask1-15.txt 43 ms 932 KB
subtask1-16.txt 46 ms 808 KB
subtask1-17.txt 45 ms 932 KB
subtask1-18.txt 46 ms 920 KB
subtask1-19.txt 41 ms 928 KB
subtask1-20.txt 43 ms 800 KB
subtask1-21.txt 45 ms 804 KB
subtask1-22.txt 44 ms 928 KB
subtask1-23.txt 41 ms 920 KB
subtask1-24.txt 45 ms 848 KB
subtask1-25.txt 45 ms 808 KB
subtask1-26.txt 45 ms 928 KB
subtask1-27.txt 48 ms 920 KB
subtask1-28.txt 41 ms 800 KB
subtask1-29.txt 47 ms 800 KB
subtask1-30.txt 46 ms 924 KB