Submission #315229


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

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

int A,B,C,D,N;

int main(){
  double h,w;
  //  cin >> h >> w;
  //  double a = 60;
  //  h = 1; w = 2;
  //  cout << h*sin(toRad(90-a)) +  w*sin(toRad(a))<< endl;
  //  cout << w*cos(toRad(a)) +  h*cos(toRad(90-a)) << endl;

  cin >> A >> B >> N;
  if(A>B) swap(A,B);
  rep(i,N){
    cin >> C >> D;
    double lb = 0.0, ub = 90;
    for(int m=0;m<2;m++){
      swap(C,D);
      if(A<=C&&B<=D){
	cout << "YES\n";
	break;
      }
      for(int l=0;l<100;l++){
	double mid = (lb+ub)/2.0;
	h = A*sin(toRad(mid)) + B*cos(toRad(mid));
	w = A*cos(toRad(mid)) + B*sin(toRad(mid));
	if(h <= C && w <= D){
	  cout << "YES\n";
	  goto e;
	}else if(w > D){
	  ub = mid;
	}else{
	  lb = mid;
	}
      }
      if(m==1) cout << "NO\n";
    }
  e:;
  }
  
  return 0;
}

Submission Info

Submission Time
Task B - 高橋君と禁断の書
User raven38
Language C++ (G++ 4.6.4)
Score 100
Code Size 1716 Byte
Status
Exec Time 142 ms
Memory 1136 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 31 ms 1068 KB
subtask1-01.txt 27 ms 948 KB
subtask1-02.txt 37 ms 1040 KB
subtask1-03.txt 65 ms 968 KB
subtask1-04.txt 59 ms 948 KB
subtask1-05.txt 84 ms 952 KB
subtask1-06.txt 96 ms 1048 KB
subtask1-07.txt 63 ms 1064 KB
subtask1-08.txt 94 ms 948 KB
subtask1-09.txt 104 ms 1056 KB
subtask1-10.txt 127 ms 1132 KB
subtask1-11.txt 85 ms 1052 KB
subtask1-12.txt 65 ms 1048 KB
subtask1-13.txt 86 ms 1032 KB
subtask1-14.txt 111 ms 1132 KB
subtask1-15.txt 89 ms 1048 KB
subtask1-16.txt 132 ms 984 KB
subtask1-17.txt 79 ms 1048 KB
subtask1-18.txt 89 ms 944 KB
subtask1-19.txt 80 ms 952 KB
subtask1-20.txt 100 ms 1052 KB
subtask1-21.txt 136 ms 1128 KB
subtask1-22.txt 136 ms 1124 KB
subtask1-23.txt 112 ms 952 KB
subtask1-24.txt 142 ms 1044 KB
subtask1-25.txt 139 ms 1136 KB
subtask1-26.txt 122 ms 1132 KB
subtask1-27.txt 105 ms 1128 KB
subtask1-28.txt 134 ms 1124 KB
subtask1-29.txt 134 ms 968 KB
subtask1-30.txt 131 ms 1044 KB