제출 #1333506

#제출 시각아이디문제언어결과실행 시간메모리
1333506mfmme23Nicelines (RMI20_nicelines)C++20
0 / 100
49 ms476 KiB
#include "nice_lines.h"
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


const long double X_VAL = 20000000; 
const long double EPS = 1e-9;


long double get_slope(long double y) {
    long double delta = 1e-4;
    long double val1 = query(X_VAL, y - delta);
    long double val2 = query(X_VAL, y + delta);
    return (val2 - val1) / (2.0 * delta);
}


void find_lines(long double y_low, long double y_high, long double s_low, long double s_high, vector<long double>& roots) {
  
    if (abs(s_high - s_low) < EPS) {
        return;
    }
    
 
    if (y_high - y_low < 0.5) {
        roots.push_back((y_low + y_high) / 2.0);
        return;
    }
    
    long double y_mid = (y_low + y_high) / 2.0;
    long double s_mid = get_slope(y_mid);
    

    find_lines(y_low, y_mid, s_low, s_mid, roots);
    find_lines(y_mid, y_high, s_mid, s_high, roots);
}

void solve(int subtask_id, int N) {

    long double Y_MAX = 3e8; 
    
    vector<long double> roots;
    long double s_low = get_slope(-Y_MAX);
    long double s_high = get_slope(Y_MAX);
    
    find_lines(-Y_MAX, Y_MAX, s_low, s_high, roots);
    
    vector<int> a_list, b_list;
    for (long double r : roots) {

        int a = (int)round(r / X_VAL);
        int b = (int)round(r - (long double)a * X_VAL);
        a_list.push_back(a);
        b_list.push_back(b);
    }
    
    the_lines_are(a_list, b_list); 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...