QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#103491#5667. Meeting Placescardinal_city#WA 3ms3772kbC++173.7kb2023-05-06 07:44:352023-05-06 07:44:38

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-06 07:44:38]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3772kb
  • [2023-05-06 07:44:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define rep(i,j,k) for (int i = j; i < (k); i++)
#define in(mp, v) (mp.find(v) != mp.end())
#define smx(a, b) a = max(a, b)
#define smn(a, b) a = min(a, b)
#define pb push_back
#define endl '\n'

#define printv(v) for (auto c : v) cout << c.first << ": " << c.second << " "; cout << "\n";


const ll MOD = 1e9 + 7;
const ld EPS2 = 1e-6;

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};

typedef Point<double> P;
double ccRadius(const P& A, const P& B, const P& C) {
	return (B-A).dist()*(C-B).dist()*(A-C).dist()/
			abs((B-A).cross(C-A))/2;
}
P ccCenter(const P& A, const P& B, const P& C) {
	P b = C-A, c = B-A;
	return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;
}

deque<pair<double, int>> mec(const vector<P>& ps, int bound) {
	P o = ps[0];

    deque<pair<double, int>> moves = {{0.0, -1}};
	double r = 0, EPS = 1 + 1e-8;
	for (int i = bound; i >= 0; i--) {
        if ((o - ps[i]).dist() > r * EPS) {
            o = ps[i], r = 0;
            rep(j,0,i) if ((o - ps[j]).dist() > r * EPS) {
                o = (ps[i] + ps[j]) / 2;
                r = (o - ps[i]).dist();
                rep(k,0,j) if ((o - ps[k]).dist() > r * EPS) {
                    o = ccCenter(ps[i], ps[j], ps[k]);
                    r = (o - ps[i]).dist();
                }
            }
        }
        if (abs(moves.back().first - r) > r * EPS2) {
            moves.push_back({moves.back().first, i + 1});
        }
    }

    moves.push_back({r, 1});
    moves.pop_front();

    // cout << bound << ": ";
    // printv(moves);


    return moves;
}


int main() {
    cin.tie(0)->sync_with_stdio(0);

    int k, n; ll x; cin >> n >> k >> x;
    ll y = 0;
    vector<P> pts(n);
    for (int i = 0; i < n; i++) {
        y = (x * 233811181 + 1) % ((1ll << 31) - 1);
        pts[i] = Point<double>{x, y};
        x = (y * 233811181 + 1) % ((1ll << 31) - 1);
    }

    vector dp(k + 1, vector<double>(n + 1, 1.0e50));
    dp[0][0] = 0.0;
    vector<vector<pair<double, int>>> comp;

    for (int i = 0; i < n; i++) {
        auto vec = mec(pts, i);

        for (int l = 1; l <= k; l++) {
            for (auto [r, j] : vec) {
                if (j < l) continue;
                dp[l][i] = min(dp[l][i], dp[l - 1][j - 1] + r);
            }
        }
    }

    cout << fixed << setprecision(15) << dp[k][n - 1] << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3772kb

input:

100 23 213

output:

0.000000000000000

result:

wrong answer 1st numbers differ - expected: '1319350480.8007326', found: '0.0000000', error = '1.0000000'