Submission #1333517

#TimeUsernameProblemLanguageResultExecution timeMemory
1333517mfmme23Nicelines (RMI20_nicelines)C++20
77.80 / 100
23 ms424 KiB
#include "nice_lines.h"
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

struct Line {
    int a, b;
};


void find_lines(long double x, long double y_low, long double y_high, 
                long double f_low, long double f_high, vector<long double>& intersections) {
    
  
    long double y_mid = (y_low + y_high) / 2.0;
    long double f_mid = query(x, y_mid);

    if (abs(f_mid - (f_low + f_high) / 2.0) < 1e-9) {
        return;
    }

    if (y_high - y_low < 0.5) {
        intersections.push_back(round(y_mid));
        return;
    }


    find_lines(x, y_low, y_mid, f_low, f_mid, intersections);
    find_lines(x, y_mid, y_high, f_mid, f_high, intersections);
}

void solve(int subtask_id, int N) {

    long double constant_x = 20001; 

    long double y_min = -210000000.0;
    long double y_max = 210000000.0;
    
    vector<long double> intercepts;
    find_lines(constant_x, y_min, y_max, query(constant_x, y_min), query(constant_x, y_max), intercepts);
    
    vector<int> va, vb;
    for (long double y_val : intercepts) {
   
        int a = round(y_val / constant_x);
        int b = round(y_val - (long double)a * constant_x);
        va.push_back(a);
        vb.push_back(b);
    }


    the_lines_are(va, vb);
}
#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...