Submission #315224


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, 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(90-mid)) + B*sin(toRad(mid));
	w = A*cos(toRad(90-mid)) + B*cos(toRad(mid));
	if(h <= C && w <= D){
	  cout << "YES\n";
	  goto e;
	}else if(h < A){
	  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 0
Code Size 1720 Byte
Status
Exec Time 233 ms
Memory 964 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 25 ms 792 KB
subtask1-01.txt 25 ms 928 KB
subtask1-02.txt 42 ms 928 KB
subtask1-03.txt 96 ms 808 KB
subtask1-04.txt 81 ms 920 KB
subtask1-05.txt 126 ms 964 KB
subtask1-06.txt 148 ms 920 KB
subtask1-07.txt 87 ms 916 KB
subtask1-08.txt 144 ms 728 KB
subtask1-09.txt 160 ms 860 KB
subtask1-10.txt 216 ms 800 KB
subtask1-11.txt 123 ms 928 KB
subtask1-12.txt 72 ms 928 KB
subtask1-13.txt 131 ms 924 KB
subtask1-14.txt 167 ms 924 KB
subtask1-15.txt 120 ms 924 KB
subtask1-16.txt 206 ms 928 KB
subtask1-17.txt 109 ms 924 KB
subtask1-18.txt 132 ms 800 KB
subtask1-19.txt 121 ms 928 KB
subtask1-20.txt 154 ms 804 KB
subtask1-21.txt 220 ms 800 KB
subtask1-22.txt 233 ms 864 KB
subtask1-23.txt 168 ms 840 KB
subtask1-24.txt 231 ms 920 KB
subtask1-25.txt 221 ms 928 KB
subtask1-26.txt 194 ms 924 KB
subtask1-27.txt 158 ms 932 KB
subtask1-28.txt 218 ms 928 KB
subtask1-29.txt 212 ms 864 KB
subtask1-30.txt 232 ms 932 KB