Submission #241560


Source Code Expand

Copy
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-9;
const int INF = 1<<25;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;

bool check(int A, int B, int C, int D){
	if(A<C && B<D) return true;
	if(B>D && A<C){
		double r1 = 0.0, r2 = PI/2.0;
		while(r2-r1>EPS){
			double r3 = (r1+r2)/2;
			if(B*cos(r3)+A*sin(r3)<=D) r2 = r3;
			else r1 = r3;
		}
		return B*sin(r2)+A*cos(r2)<=C;
	}
	return false;
}

int main(){
	int A, B, N;
	cin>>A>>B>>N;
	if(A>B) swap(A,B);
	for(int i = 0; i < N; i++){
		int C, D;
		cin>>C>>D;
		if(C>D) swap(C,D);
		cout<<(check(A,B,C,D)?"YES":"NO")<<endl;
	}
	return 0;
}

Submission Info

Submission Time
Task B - 高橋君と禁断の書
User Lepton
Language C++ (G++ 4.6.4)
Score 100
Code Size 1060 Byte
Status
Exec Time 55 ms
Memory 804 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 27 ms 668 KB
subtask1-01.txt 26 ms 800 KB
subtask1-02.txt 28 ms 712 KB
subtask1-03.txt 40 ms 800 KB
subtask1-04.txt 41 ms 736 KB
subtask1-05.txt 42 ms 800 KB
subtask1-06.txt 49 ms 796 KB
subtask1-07.txt 45 ms 796 KB
subtask1-08.txt 44 ms 672 KB
subtask1-09.txt 50 ms 800 KB
subtask1-10.txt 49 ms 800 KB
subtask1-11.txt 48 ms 800 KB
subtask1-12.txt 49 ms 804 KB
subtask1-13.txt 51 ms 672 KB
subtask1-14.txt 51 ms 664 KB
subtask1-15.txt 47 ms 800 KB
subtask1-16.txt 48 ms 800 KB
subtask1-17.txt 51 ms 716 KB
subtask1-18.txt 49 ms 796 KB
subtask1-19.txt 55 ms 800 KB
subtask1-20.txt 55 ms 800 KB
subtask1-21.txt 55 ms 676 KB
subtask1-22.txt 48 ms 800 KB
subtask1-23.txt 50 ms 804 KB
subtask1-24.txt 54 ms 672 KB
subtask1-25.txt 50 ms 736 KB
subtask1-26.txt 51 ms 800 KB
subtask1-27.txt 49 ms 796 KB
subtask1-28.txt 49 ms 672 KB
subtask1-29.txt 50 ms 796 KB
subtask1-30.txt 49 ms 804 KB