QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#737906 | #5667. Meeting Places | GU_777 | WA | 1ms | 6156kb | C++23 | 5.7kb | 2024-11-12 17:08:03 | 2024-11-12 17:08:03 |
Judging History
answer
#include <bits/stdc++.h>
// #pragma GCC optimize(1,2,3,"Ofast","inline")
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
#define int i64
#define FF first
#define SS second
#define SZ(x) ((i32)(x).size())
#define PB push_back
#define EB emplace_back
#define all(x) (x).begin(), (x).end()
using i128 = __int128_t;
using ui64 = uint64_t;
using i64 = int64_t;
using ui32 = uint32_t;
using i32 = int32_t;
using ld = long double;
using P32 = pair<i32, i32>;
using P64 = pair<i64, i64>;
const i64 INF = 1e18;
const ld eps = 1e-8L;
// mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
// i64 randint(i64 l, i64 r) { uniform_int_distribution<> dis(l, r); return dis(mt); }
// double randld(i64 l, i64 r) { uniform_real_distribution<> dis(l, r); return dis(mt); }
void debug() {}
template<class T> void debug(T var) { cerr << var; }
template<class T, class ...P> void debug(T var, P ...t) { cerr << var << ", "; debug(t...); }
template<class T> void org(T l, T r) { while(l != r) cerr << *l++ << ' '; }
#define de(...) { cerr << "[Line: " << __LINE__ << "][" << #__VA_ARGS__ << "] -> [", debug(__VA_ARGS__), cerr << "]\n"; }
#define orange(...) { cerr << "[Line: " << __LINE__ << "][" << #__VA_ARGS__ << "] -> [", org(__VA_ARGS__), cerr << "]\n"; }
const size_t msize = 200000;
char buf[msize], *p1 = buf, *p2 = buf;
char obuf[msize], *p3 = obuf;
#define getc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, msize, stdin), p1 == p2) ? EOF : *p1++)
#define putac(x) (p3 - obuf < msize) ? (*p3 ++ = x) :(fwrite(obuf, p3 - obuf, 1, stdout), p3 = obuf, *p3 ++ = x)
template<class T> inline void read(T &x) {
x = 0;
i32 f = 1;
char ch = getc();
for (; ch < 48 || ch > 57; ch = getc()) if (ch == '-') f = -1;
for (; ch >= 48 && ch <= 57; ch = getc()) x = (x << 3) + (x << 1) + (ch ^ 0x30);
x = x * f;
}
template<class T> void write(const T &x) {
static int32_t c[40];
if (!x) { putac('0'); return; }
i32 len = 0;
T k1 = x;
if (k1 < 0) k1 = -k1, putac('-');
while (k1) c[len++] = k1 % 10 ^ 48, k1 /= 10;
while (len--) putac(c[len]);
}
template<typename T, typename... Args>
inline void read(T &x, Args&... args) {
read(x); // 讀取第一個變數
(read(args), ...); // 展開剩餘變數的讀取
}
void OUO();
i32 main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(10);
i32 t = 1;
// t = read<i32>();
for (i32 tt = 0; tt < t; tt++){
OUO();
}
fwrite(obuf, p3 - obuf, 1, stdout);
}
const int mod = 2147483647;
template<class T>
struct pt{
T x,y;
pt(T _x,T _y):x(_x),y(_y){}
pt():x(0),y(0){}
pt operator * (T c){ return pt(x*c,y*c);}
pt operator / (T c){ return pt(x/c,y/c);}
pt operator + (pt a) const { return pt(x+a.x,y+a.y);}
pt operator - (pt a) const { return pt(x-a.x,y-a.y);}
T operator * (pt a){ return x*a.x + y*a.y;}
T operator ^ (pt a){ return x*a.y - y*a.x;}
auto operator<=>(pt o) const { return (x != o.x) ? x <=> o.x : y <=> o.y; } // c++20
bool operator < (pt a) const { return x < a.x || (x == a.x && y < a.y);};
bool operator== (pt a) const { return x == a.x and y == a.y;};
friend T ori(pt a, pt b, pt c) { return (b - a) ^ (c - a); }
friend T abs2(pt a) { return abs(a * a); }
};
using Pt = pt<ld>;
int sgn(ld x) { return (x > -eps) - (x < eps); } // dcmp == sgn
ld abs(Pt a) { return sqrt(abs2(a)); }
Pt rotate(Pt u) { // pi / 2
return {-u.y, u.x};
}
struct Line {
Pt a, b;
Pt dir() const { return b - a; }
};
Pt LineInter(Line l, Line m) {
double s = ori(m.a, m.b, l.a), t = ori(m.a, m.b, l.b);
return (l.b * s - l.a * t) / (s - t);
}
Pt Center(Pt a, Pt b, Pt c) {
Pt x = (a + b) / 2;
Pt y = (b + c) / 2;
return LineInter({x, x + rotate(b - a)}, {y, y + rotate(c - b)});
}
struct Cir {
Pt o;
ld r;
bool inside(const Pt &a) {
// abs(a - o) <= r
return sgn(abs(a - o) - r) <= 0;
}
};
ld ww[2005][2005], dp[2005];
vector<int> have[2005];
Cir MEC(vector<Pt> P, int start) {
have[start + 1].PB(0);
Cir C = {P[0], 0.0L};
for (int i = 0; i < P.size(); i++) {
ww[start + 1][i + start + 1] = C.r;
if (C.inside(P[i])) continue;
have[i + start + 1].PB(start + 1);
C = {P[i], 0};
for (int j = 0; j < i; j++) {
if (C.inside(P[j])) continue;
C = {(P[i] + P[j]) / 2, abs(P[i] - P[j]) / 2};
for (int k = 0; k < j; k++) {
if (C.inside(P[k])) continue;
C.o = Center(P[i], P[j], P[k]);
C.r = abs(C.o - P[i]);
}
}
ww[start + 1][i + start + 1] = C.r;
}
return C;
}
ostream &operator<<(ostream &s, const Pt &a) { return s << a.x << ' ' << a.y << '\n'; }
int calc(int x) {
return (x * 233811181) % mod + 1 % mod;
}
void OUO() {
int n, k, x; read(n, k, x);
vector<P64> vec(n);
vec[0] = P64(x, calc(x));
for (i32 i = 1; i < n; i++) {
vec[i].FF = calc(vec[i - 1].SS);
vec[i].SS = calc(vec[i].FF);
}
vector<Pt> pts(n);
for (i32 i = 0; i < n; i++)
pts[i] = Pt(vec[i].FF, vec[i].SS);
// MEC(pts, 0);
for (i32 i = 0; i < n; i++) {
vector<Pt> tmp(pts.begin() + i, pts.end());
if (tmp.size()) MEC(tmp, i);
}
for (i32 j = 1; j < 2005; j++) dp[j] = 1e100L;
for (i32 i = 1; i <= k; i++) {
for (i32 j = n; j >= 1; j--) {
for (i32 l : have[j]) dp[j] = min(dp[j], dp[l] + ww[l + 1][j]);
}
}
cout << dp[n];
}
// https://vjudge.net/problem/QOJ-5667
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6156kb
input:
100 23 213
output:
1319350480.8007325387
result:
ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
10 1 1060
output:
1042753143.3451676866
result:
ok found '1042753143.3451676', expected '1042753143.3451676', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5948kb
input:
10 10 2373
output:
0.0000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 5884kb
input:
10 2 3396
output:
1305327616.8448314156
result:
wrong answer 1st numbers differ - expected: '1236610536.9469230', found: '1305327616.8448315', error = '0.0555689'