QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#186087 | #5667. Meeting Places | aesthetic | WA | 2ms | 9996kb | C++20 | 6.4kb | 2023-09-23 06:03:20 | 2023-09-23 06:03:21 |
Judging History
answer
#include "bits/stdc++.h"
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
#define int long long
#define dbg_loc() cerr << __PRETTY_FUNCTION__ << " : " << __LINE__ << "\n"
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p){
return os << '(' << p.first << ", " << p.second << ')';
}
template<typename T_container,typename T=typename enable_if<!is_same<T_container,string>::value, typename T_container::value_type>::type>
ostream& operator<<(ostream &os, const T_container &v){
os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}';
}
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){
cerr << ' ' << H;
dbg_out(T...);
}
#define LOCAL
#define LOCAL
#ifdef LOCAL
#define dbg(...) cerr<<"(" << #__VA_ARGS__<<"):" , dbg_out(__VA_ARGS__) , cerr << endl
#else
#define dbg(...)
#endif
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
// ll mod = (1000000007LL);
// inline ll Mod(ll a, ll b){return (a%b);}
// inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
///CUIDADO COM MAXN
#define N 50010 // 1E6
const int B =233811181;
const int mod = (1LL<<31) - 1;
int n, k, x[N], y[N];
int x1;
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; }
long double dist() const { return sqrt((long double)dist2()); }
// angle to x-axis in interval [-pi, pi]
long 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(long 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<long double> P;
long 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;
}
pair<P, long double> mec(vector<P> ps) {
shuffle(all(ps), mt19937(time(0)));
P o = ps[0];
long double r = 0, EPS = 1 + 1e-8;
rep(i,0,sz(ps)) 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();
}
}
}
return {o, r};
}
vector<P> pts;
long double cost2[2010][2010];
struct DP{
int n ;
long double inf;
vector<long double> dp[2];
DP(int n , long double inf) : n(n) , inf(inf) {dp[0] = vector<long double>(n+1) , dp[1] = vector<long double>(n+1);}
long double cost(int i,int j){
assert(i<=j);
return cost2[i][j];
}
// compute dp_cur[l], ... dp_cur[r] (inclusive)
void compute(int l, int r, int optl, int optr){
if (l > r) return;
int mid = l + (r-l)/2;
pair<long double, int> best = {inf, -1}; // se for maximizar muda pra -inf
rep(k,optl,min(mid,optr)+1){
best = min(best, { dp[0][k-1] + cost(k,mid), k});
}
dp[1][mid] = best.first; int opt = best.second;
compute(l, mid - 1, optl, opt);
compute(mid + 1, r, opt, optr);
}
void solve(int k){
rep(i,1,n+1){
dp[0][i] = cost(1,i);
// dbg(dp[0][i]);
}
rep(i,2,k+1){
rep(j,i,n+1) dp[1][j] = inf;
compute(i,n,i,n) ;
swap(dp[0] , dp[1]);
}
}
};
long double pica[2010][2010];
vi caras[2010];
int32_t main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>k>>x1;
pts.resize(n);
x[1] = x1%mod;
y[1] = (x1*B + 1)%mod;
pts[0] = P(x[1], y[1]);
rep(i,2,n+1){
x[i] = (y[i-1] * B + 1) % mod;
y[i] = (x[i]*B + 1) %mod;
pts[i-1] = P(x[i], y[i]);
}
rep(ini, 0, n){
vector<P> ps;
rep(i, ini, n) ps.pb(pts[i]);
P o = ps[0];
long double r = 0, EPS = 1 + 1e-8;
rep(i,0,sz(ps)){
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;
caras[i + ini+1].pb(j+ini+1);
caras[i + ini+1].pb(ini+1);
r = (o - ps[i]).dist();
rep(k,0,j) if ((o - ps[k]).dist() > r * EPS) {
caras[i+ini+1].pb(k+ini+1);
caras[j+ini+1].pb(k+ini+1);
caras[j + ini+1].pb(ini+1);
caras[k + ini+1].pb(ini+1);
o = ccCenter(ps[i], ps[j], ps[k]);
r = (o - ps[i]).dist();
}
}
caras[ini + i+1].pb(ini+1);
}
int fim = ini + i;
cost2[ini+1][fim+1] = r;
}
caras[ini+1].pb(ini+1);
caras[ini+1].pb(1);
}
// k * n * X <= 2e8
// X = 2e8/(n*k)
long double ans = 2e18;
for(int i = 1; i <= n; i++){
//n-k+1
int j = i+(n-k+1)-1;
if(j>n) continue;
ans=min(ans, cost2[i][j]);
}
cout<<setprecision(20)<<"\n";
// DP dp(n, 2e18);
// dp.solve(k);
// cout<<dp.dp[0][n]<<"\n";
cout<<ans<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 8284kb
input:
100 23 213
output:
1319350480.8007325387
result:
ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 6052kb
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: 9992kb
input:
10 10 2373
output:
0
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5992kb
input:
10 2 3396
output:
1236610536.9469230312
result:
ok found '1236610536.9469230', expected '1236610536.9469230', error '0.0000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5992kb
input:
10 3 1998
output:
973790809.82244422752
result:
ok found '973790809.8224442', expected '973790809.8224442', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 9996kb
input:
10 4 562
output:
910867389.90693293762
result:
ok found '910867389.9069330', expected '910867389.9069330', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 6000kb
input:
10 5 6048
output:
818240814.710514982
result:
ok found '818240814.7105150', expected '818240814.7105150', error '0.0000000'
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 6032kb
input:
10 6 2524
output:
674787674.312985425
result:
wrong answer 1st numbers differ - expected: '500106979.3467762', found: '674787674.3129854', error = '0.3492867'