답안 #750950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750950 2023-05-30T16:32:42 Z doowey Nicelines (RMI20_nicelines) C++14
86.7093 / 100
62 ms 600 KB
#include <bits/stdc++.h>
#include "nice_lines.h"

using namespace std;

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

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

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

map<ll, ld> st;

ld Q(ll x){
    if(!st.count(x)) st[x] = query(X, x);
    return st[x];
}

ld g(ll x){
    return Q(x) - Q(x - 1);
}


vector<int> aa, bb;

int n;

void go(ll l, ll r, ld gl, ld gr){
    if(abs(gl-gr) < EPS)  return;
    if(aa.size() == n) return;
    if(l + 1 == r){
        int B = (l % X + X) % X;
        if(B > (int)1e4) B = -(X - B);
        int A = (l - B) / X;
        aa.push_back(A);
        bb.push_back(B);
        return;
    }
    ll mid = l + (r - l) / 2ll;
    ld gm = g(mid);
    if(abs(gm-gl) > EPS){
        go(l, mid, gl, gm);
    }
    if(abs(gm-gr) > EPS){
        go(mid, r, gm, gr);
    }
}

void solve(int _id, int _n){
    n = _n;
    go(-B, +B, g(-B), g(+B));
    the_lines_are(aa, bb);
}

Compilation message

nicelines.cpp: In function 'void go(ll, ll, ld, ld)':
nicelines.cpp:37:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     if(aa.size() == n) return;
      |        ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 2 ms 296 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 320 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 45 ms 548 KB Output is partially correct
2 Partially correct 52 ms 456 KB Output is partially correct
3 Partially correct 58 ms 448 KB Output is partially correct
4 Partially correct 61 ms 552 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 29 ms 352 KB Output is partially correct
2 Partially correct 44 ms 364 KB Output is partially correct
3 Partially correct 25 ms 352 KB Output is partially correct
4 Partially correct 20 ms 324 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 45 ms 548 KB Output is partially correct
2 Partially correct 52 ms 456 KB Output is partially correct
3 Partially correct 58 ms 448 KB Output is partially correct
4 Partially correct 61 ms 552 KB Output is partially correct
5 Partially correct 29 ms 352 KB Output is partially correct
6 Partially correct 44 ms 364 KB Output is partially correct
7 Partially correct 25 ms 352 KB Output is partially correct
8 Partially correct 20 ms 324 KB Output is partially correct
9 Partially correct 39 ms 600 KB Output is partially correct
10 Partially correct 62 ms 512 KB Output is partially correct
11 Partially correct 58 ms 584 KB Output is partially correct
12 Partially correct 43 ms 544 KB Output is partially correct