Submission #750838

# Submission time Handle Problem Language Result Execution time Memory
750838 2023-05-30T11:17:10 Z doowey Nicelines (RMI20_nicelines) C++14
85.2708 / 100
73 ms 304 KB
#include <bits/stdc++.h>
#include "nice_lines.h"

using namespace std;

typedef long double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair

const int X = (int)2e4 + 4;
const int B = X * 1ll * X;
const ld EPS = 1e-5;

bool on_line(ld x0, ld y0, ld x1, ld y1, ld x2, ld y2){
    return abs((x2 - x1) * (y1 - y0) - (y2 - y1) * (x1 - x0)) < EPS;
}

vector<int> aa, bb;
int nn;

bool solve(int lef, int rig, ld la, ld ra){
    if(aa.size() == nn) return false;
    if(la < 0.0){
        la = query(X, (ld)lef - 0.5);
    }
    if(ra < 0.0){
        ra = query(X, (ld)rig + 0.5);
    }
    if(lef == rig){
        ld ma = query(X, lef);
        if(on_line(lef - 0.5, la, lef, ma, rig + 0.5, ra)) return false;
        int B = (lef % X + X) % X;
        if(B > (int)1e4) B = -(X-B);
        int A = (lef - B) / X;
        //cout << lef << " " << A << " " << B << "\n";
        aa.push_back(A);
        bb.push_back(B);
        return true;
    }
    int mid = lef + (rig - lef) / 2;
    ld ma = query(X, (ld)mid + 0.5);
    if(on_line(lef - 0.5, la, mid + 0.5, ma, rig + 0.5, ra)) return false;

    if(rig == lef + 1){
        if(solve(lef, mid, la, ma)) return false;
        int B = (rig % X + X) % X;
        if(B > (int)1e4) B = -(X-B);
        int A = (rig - B) / X;
        aa.push_back(A);
        bb.push_back(B);
        return false;
    }

    solve(mid + 1, rig, ma, ra);
    solve(lef, mid, la, ma);
    return false;


}

void solve(int subtask_id, int N) {
    nn = N;
    /*
    printf("subtask_id = %d, N = %d\n", subtask_id, N);
    printf("query(0, 0) = %Lf\n", query(0, 0));
    printf("query(1, 1) = %Lf\n", query(1, 1));
    */
    solve(-B, B, -1.0, -1.0);
    the_lines_are(aa, bb);
}

Compilation message

nicelines.cpp: In function 'bool solve(int, int, ld, ld)':
nicelines.cpp:25:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     if(aa.size() == nn) return false;
      |        ~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 296 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 55 ms 304 KB Output is partially correct
2 Partially correct 57 ms 292 KB Output is partially correct
3 Partially correct 73 ms 292 KB Output is partially correct
4 Partially correct 33 ms 296 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 21 ms 208 KB Output is partially correct
2 Partially correct 20 ms 208 KB Output is partially correct
3 Partially correct 18 ms 208 KB Output is partially correct
4 Partially correct 15 ms 208 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 55 ms 304 KB Output is partially correct
2 Partially correct 57 ms 292 KB Output is partially correct
3 Partially correct 73 ms 292 KB Output is partially correct
4 Partially correct 33 ms 296 KB Output is partially correct
5 Partially correct 21 ms 208 KB Output is partially correct
6 Partially correct 20 ms 208 KB Output is partially correct
7 Partially correct 18 ms 208 KB Output is partially correct
8 Partially correct 15 ms 208 KB Output is partially correct
9 Partially correct 60 ms 208 KB Output is partially correct
10 Partially correct 55 ms 296 KB Output is partially correct
11 Partially correct 38 ms 304 KB Output is partially correct
12 Partially correct 59 ms 292 KB Output is partially correct