Submission #315225


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(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 1716 Byte
Status
Exec Time 184 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 25 ms 916 KB
subtask1-01.txt 26 ms 920 KB
subtask1-02.txt 40 ms 932 KB
subtask1-03.txt 82 ms 800 KB
subtask1-04.txt 77 ms 928 KB
subtask1-05.txt 107 ms 924 KB
subtask1-06.txt 126 ms 884 KB
subtask1-07.txt 75 ms 924 KB
subtask1-08.txt 117 ms 920 KB
subtask1-09.txt 133 ms 920 KB
subtask1-10.txt 170 ms 928 KB
subtask1-11.txt 124 ms 800 KB
subtask1-12.txt 78 ms 928 KB
subtask1-13.txt 114 ms 804 KB
subtask1-14.txt 144 ms 924 KB
subtask1-15.txt 107 ms 808 KB
subtask1-16.txt 160 ms 932 KB
subtask1-17.txt 100 ms 928 KB
subtask1-18.txt 106 ms 800 KB
subtask1-19.txt 107 ms 932 KB
subtask1-20.txt 135 ms 800 KB
subtask1-21.txt 171 ms 928 KB
subtask1-22.txt 184 ms 924 KB
subtask1-23.txt 146 ms 884 KB
subtask1-24.txt 183 ms 856 KB
subtask1-25.txt 177 ms 916 KB
subtask1-26.txt 156 ms 792 KB
subtask1-27.txt 138 ms 892 KB
subtask1-28.txt 169 ms 932 KB
subtask1-29.txt 166 ms 932 KB
subtask1-30.txt 177 ms 932 KB