Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <string.h>
- using namespace std;
- typedef vector<double> vd;
- double dist(double p1[], double p2[]) {
- return sqrt((p1[0] - p2[0])*(p1[0] - p2[0]) + (p1[1] - p2[1])*(p1[1] - p2[1]));
- }
- double cons[] = {(2*M_PI)/double(12), (2*M_PI)/double(60)};
- double cross(double p1[], double p2[]) {
- return p1[0]*p2[1] - p1[1]*p2[0];
- }
- double area(int h, int m, int s) {
- double p1[] = {3*sin(h*cons[0]), 3*cos(h*cons[0])};
- double p2[] = {4*sin(m*cons[1]), 4*cos(m*cons[1])};
- double p3[] = {5*sin(s*cons[1]), 5*cos(s*cons[1])};
- if (cross(p1,p2) <= 0.0001 and cross(p3,p1) <= 0.0001) return 0;
- double c1 = dist(p1, p2), c2 = dist(p2, p3), c3 = dist(p3, p1);
- double a = (c1 + c2 + c3)/2;
- if (h == 1 and m == 35 and s == 5) {
- cout << p1[0] << " " << p1[1] << endl;
- cout << p2[0] << " " << p2[1] << endl;
- cout << p3[0] << " " << p3[1] << endl;
- cout << c1 << " " << c2 << " " << c3 << " " << a << endl;
- cout << sqrt(a*(a-c1)*(a-c2)*(a-c3)) << endl;
- }
- return sqrt(a*(a - c1)*(a-c2)*(a-c3));
- }
- double* it;
- int h;
- void start(int n) {
- h = 1;
- while (h < 2*n) h *= 2;
- it = new double[h];
- memset(it, 0, sizeof(it));
- }
- void insert(double n, int i) {
- it[h/2 + i] = n;
- for (int j = (h/2 + i)/2; j > 0; j /= 2) it[j] = max(it[2*j], it[2*j + 1]);
- }
- double maxi(int i, int j, int a = 1, int ai = 0, int aj = h/2-1) {
- int m = (ai + aj)/2;
- if (i <= ai and aj <= j) return it[a];
- if (i > aj or j < ai) return 0;
- return max(maxi(i, j, 2*a, ai, m), maxi(i, j, 2*a + 1, m + 1, aj));
- }
- int main() {
- cout.setf(ios::fixed);
- cout.precision(3);
- vd aux(12*3600 + 60*60 + 60);
- for (int i = 0; i < 12; ++i) for (int j = 0; j < 60; ++j) for (int k = 0; k < 60; ++k)
- aux[i*3600 + 60*j + k] = area(i,j,k);
- start(aux.size());
- for (int i = 0; i < aux.size(); ++i) insert(aux[i], i);
- int h1, h2, m1, m2, s1, s2; char c;
- while (cin>>h1>>c>>m1>>c>>s1>>h2>>c>>m2>>c>>s2)
- cout << maxi(h1*3600 + m1*60 + s1,h2*3600 + m2*60 + s2) << endl;
- }
Add Comment
Please, Sign In to add comment