Submission #243642


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;
typedef pair<int, int> P;


#define INF 1000000000
#define EPS 1e-10

#define MAX_A 300000
#define MAX_B 300000

#define MAX_N 5000

#define PI (atan(1.0) * 4.0)

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

int main() {

	cin >> A >> B;

	if (A > B)
		swap(A, B);

	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> C[i] >> D[i];
		if (C[i] > D[i])
			swap(C[i], D[i]);
	}

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

		if ((A <= C[i] && B <= D[i]) || (A <= D[i] && B <= C[i])){
			cout << "YES" << endl;
			continue;
		}

		double lb = 0, ub = PI / 2;

		bool flag = false;

		while (ub - lb > EPS){
			double rad = (ub + lb) / 2;
			double h = B*sin(rad) + A * cos(rad);
			if (h < D[i])
				lb = rad;
			else
				ub = rad;
		}
		double rad = (ub + lb) / 2;
		double d = A * sin(rad) + B * cos(rad);
		if (C[i] - d >= 0.01)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

	}



	return 0;
}

Submission Info

Submission Time
Task B - 高橋君と禁断の書
User taketake0609
Language C++ (G++ 4.6.4)
Score 100
Code Size 1483 Byte
Status
Exec Time 82 ms
Memory 952 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0-sample-01.txt
All 100 / 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 29 ms 740 KB
subtask1-01.txt 27 ms 872 KB
subtask1-02.txt 39 ms 884 KB
subtask1-03.txt 42 ms 860 KB
subtask1-04.txt 46 ms 924 KB
subtask1-05.txt 52 ms 924 KB
subtask1-06.txt 56 ms 864 KB
subtask1-07.txt 49 ms 856 KB
subtask1-08.txt 55 ms 860 KB
subtask1-09.txt 60 ms 924 KB
subtask1-10.txt 67 ms 796 KB
subtask1-11.txt 56 ms 920 KB
subtask1-12.txt 52 ms 884 KB
subtask1-13.txt 58 ms 872 KB
subtask1-14.txt 66 ms 920 KB
subtask1-15.txt 57 ms 864 KB
subtask1-16.txt 63 ms 924 KB
subtask1-17.txt 52 ms 924 KB
subtask1-18.txt 54 ms 924 KB
subtask1-19.txt 55 ms 864 KB
subtask1-20.txt 58 ms 860 KB
subtask1-21.txt 64 ms 916 KB
subtask1-22.txt 64 ms 920 KB
subtask1-23.txt 59 ms 952 KB
subtask1-24.txt 66 ms 928 KB
subtask1-25.txt 67 ms 864 KB
subtask1-26.txt 62 ms 924 KB
subtask1-27.txt 58 ms 916 KB
subtask1-28.txt 82 ms 800 KB
subtask1-29.txt 65 ms 872 KB
subtask1-30.txt 67 ms 924 KB