QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#123444#5667. Meeting PlacesGenshinImpactsFault#TL 308ms20308kbC++144.9kb2023-07-12 16:34:472023-07-12 16:34:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-12 16:34:50]
  • 评测
  • 测评结果:TL
  • 用时:308ms
  • 内存:20308kb
  • [2023-07-12 16:34:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD ((1ll << 31) - 1)
int X[2010], Y[2010];
long double p[2010][2010];
long double dis[2010][2010];
long double get_dis(int x1, int y1, int x2, int y2) {
    long double ret = sqrt(1ll * (x1 - x2) * (x1 - x2) + 1ll * (y1 - y2) * (y1 - y2));
    return ret;
}
long double f[2010][2010];

#define fst first
#define snd second
#define pb push_back
typedef pair<long double, long double> pii;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
inline pii operator+(const pii &x, const pii &y) {
	return {x.fst + y.fst, x.snd + y.snd};
}
inline pii operator-(const pii &x, const pii &y) {
	return {x.fst - y.fst, x.snd - y.snd};
}
long double len(const pii &x) {
	return sqrt(x.fst * x.fst + x.snd * x.snd);
}
pii dir(const pii &x) {
	return (pii){x.fst / len(x), x.snd / len(x)};
}
long double angle(const pii &x) {
	pii y = dir(x);
	if(x.snd >= 0) return acos(y.fst);
	return 2 * pi - acos(y.fst);
}

pii a[2010];
struct P {
    long double x, y, r;
};

P calc(int lb, int rb) {
    int u = lb;
    for(int i = lb; i <= rb; i++) a[i] = {X[i], Y[i]};
	vector<long double> ad, rm;
	long double l = 0, r = INT_MAX, mid;
    pii cen, tmp;
	for(; r - l > eps;) {
		mid = (l + r) / 2;
		int cnt = 1, flag = 0;
		ad.clear(), rm.clear();
		for(int i = lb; i <= rb; i++) {
			if(i == u) continue;
			long double le = len(a[i] - a[u]), r1 = mid, r2 = mid;
			if(le + r1 <= r2) {
                assert(0);
			}
			if(le + r2 < r1 || r1 + r2 < le) continue;
			long double theta = angle(a[i] - a[u]), delta, tx, ty;
			delta = acos((r1 * r1 + le * le - r2 * r2) / 2 / r1 / le);
			tx = theta - delta, ty = theta + delta;
			for(; tx < 0; tx += 2 * pi, ty += 2 * pi);
			if(ty <= 2 * pi) {
				ad.pb(tx), rm.pb(ty);
			}
			else {
				ad.pb(tx), rm.pb(2 * pi), ad.pb(0), rm.pb(ty - 2 * pi);
			}
		}
		sort(ad.begin(), ad.end()), sort(rm.begin(), rm.end());
		for(auto it1 = ad.begin(), it2 = rm.begin(); it1 != ad.end() || it2 != rm.end();) {
			if(it1 != ad.end() && (it2 == rm.end() || *it1 < *it2)) {
                tmp = a[u] + (pii){cos(*it1) * mid, sin(*it1) * mid};
				++cnt, ++it1;
			}
			else --cnt, ++it2;
			if(cnt >= rb - lb + 1) {
				flag = 1; break;
			}
		}
		if(flag) cen = tmp, r = mid;
		else l = mid;
	}
    return (P){cen.fst, cen.snd, r};
}
vector<pair<int, long double>> from[2010];
signed main() {
	ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
	int n, K;
    cin >> n >> K >> X[1];
    for(int i = 1; i <= n; ++ i) {
        if(i > 1) {
            X[i] = ((Y[i - 1] * 233811181ll) + 1) % MOD;
        }
        Y[i] = ((X[i] * 233811181ll) + 1) % MOD;
    }
    for(int i = 1; i <= n; ++ i) {
        for(int j = i; j <= n; ++ j) {
            dis[i][j] = dis[j][i] = get_dis(X[i], Y[i], X[j], Y[j]);
        }
    }
    for(int i = 1; i <= n; ++ i) {
        P now = calc(i - 1, i);
        p[i - 1][i] = now.r;
        from[i].push_back({i - 1, 0});
        from[i].push_back({i - 2, p[i - 1][i]});
        for(int j = i - 2; j >= 1; -- j)  {
            if(now.r * now.r >= (X[j] - now.x) * (X[j] - now.x) + (Y[j] - now.y) * (Y[j] - now.y)) {
                p[j][i] = p[j + 1][i];
                from[i][from[i].size() - 1].first = j - 1;
            }
            else {
                now = calc(j, i);
                p[j][i] = now.r;
                from[i].push_back({j - 1, p[j][i]});
            }
            // p[i][j] = p[i][j - 1];
            // for(int k = i; k <= j - 1; ++ k) {
            //     p[i][j] = max(p[i][j], dis[k][j]);
            // } 
            // cerr << i << " " << j << " " << p[i][j] << endl;
        }

    }
    if(K <= 100) {
        for(int i = 0; i <= n; ++ i) {
            for(int j = 0; j <= n; ++ j) {
                f[i][j] = 1e18;
            }
        }
        f[0][0] = 0;
        for(int i = 1; i <= n; ++ i) {
            for(int j = 1; j <= K && j <= i; ++ j) {
                // f[i][j] = 1e15;
                for(auto [k, pp] : from[i]) {
                    f[i][j] = min(f[i][j], f[k][j - 1] + pp);
                }
                f[i][j] = min(f[i][j], f[j - 1][j - 1] + p[j][i]); 
                // for(int k = 0ll; k <= i - 1; ++ k) {
                //     // if(i == 1 && j == 1) {
                //     //     cerr << p[k + 1][i] << endl;
                //     // }
                //     f[i][j] = min(f[i][j], f[k][j - 1] + p[k + 1][i]);
                // }
                // if(i <= 20) cerr << i << " " << j << " " << f[i][j] << endl;
            }
        }
        cout << fixed << setprecision(20) << f[n][K] << endl;
    }
    else {
        long double mx = 1e18;
        for(int i = 1; i <= n && i + n - K <= n; ++ i) {
            mx = min(mx, p[i][i + n - K]);
        }
        cout << fixed << setprecision(20) << mx << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 105ms
memory: 14168kb

input:

100 23 213

output:

1319350480.80073254485614597797

result:

ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'

Test #2:

score: 0
Accepted
time: 3ms
memory: 7968kb

input:

10 1 1060

output:

1042753143.34516769286710768938

result:

ok found '1042753143.3451676', expected '1042753143.3451676', error '0.0000000'

Test #3:

score: 0
Accepted
time: 3ms
memory: 9836kb

input:

10 10 2373

output:

0.00000000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 9844kb

input:

10 2 3396

output:

1236610536.94692303542979061604

result:

ok found '1236610536.9469230', expected '1236610536.9469230', error '0.0000000'

Test #5:

score: 0
Accepted
time: 3ms
memory: 7804kb

input:

10 3 1998

output:

973790809.82244423299562186003

result:

ok found '973790809.8224442', expected '973790809.8224442', error '0.0000000'

Test #6:

score: 0
Accepted
time: 3ms
memory: 7856kb

input:

10 4 562

output:

910867389.90693294338416308165

result:

ok found '910867389.9069330', expected '910867389.9069330', error '0.0000000'

Test #7:

score: 0
Accepted
time: 2ms
memory: 7792kb

input:

10 5 6048

output:

818240814.71051498549059033394

result:

ok found '818240814.7105150', expected '818240814.7105150', error '0.0000000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 7748kb

input:

10 6 2524

output:

500106979.34677624536561779678

result:

ok found '500106979.3467762', expected '500106979.3467762', error '0.0000000'

Test #9:

score: 0
Accepted
time: 2ms
memory: 7988kb

input:

10 7 5415

output:

559478971.43200589169282466173

result:

ok found '559478971.4320059', expected '559478971.4320059', error '0.0000000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 10008kb

input:

10 8 1438

output:

500309745.46276999928522855043

result:

ok found '500309745.4627700', expected '500309745.4627700', error '0.0000000'

Test #11:

score: 0
Accepted
time: 3ms
memory: 7964kb

input:

10 9 3172

output:

162279748.87534517564927227795

result:

ok found '162279748.8753452', expected '162279748.8753452', error '0.0000000'

Test #12:

score: 0
Accepted
time: 137ms
memory: 18200kb

input:

100 1 8316

output:

1320052902.15229025902226567268

result:

ok found '1320052902.1522903', expected '1320052902.1522903', error '0.0000000'

Test #13:

score: 0
Accepted
time: 197ms
memory: 16308kb

input:

100 100 4179

output:

0.00000000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #14:

score: 0
Accepted
time: 205ms
memory: 16260kb

input:

100 12 3405

output:

1329687126.13045487995259463787

result:

ok found '1329687126.1304548', expected '1329687126.1304548', error '0.0000000'

Test #15:

score: 0
Accepted
time: 165ms
memory: 18128kb

input:

100 16 8378

output:

1338056514.48426947603002190590

result:

ok found '1338056514.4842694', expected '1338056514.4842694', error '0.0000000'

Test #16:

score: 0
Accepted
time: 144ms
memory: 18160kb

input:

100 2 1858

output:

1310392496.14305806858465075493

result:

ok found '1310392496.1430581', expected '1310392496.1430581', error '0.0000000'

Test #17:

score: 0
Accepted
time: 118ms
memory: 16128kb

input:

100 25 4596

output:

1440464106.62292967201210558414

result:

ok found '1440464106.6229296', expected '1440464106.6229298', error '0.0000000'

Test #18:

score: 0
Accepted
time: 182ms
memory: 14372kb

input:

100 3 5633

output:

1399621082.61427368433214724064

result:

ok found '1399621082.6142738', expected '1399621082.6142738', error '0.0000000'

Test #19:

score: 0
Accepted
time: 179ms
memory: 20252kb

input:

100 32 7827

output:

1342073760.53223296953365206718

result:

ok found '1342073760.5322330', expected '1342073760.5322330', error '0.0000000'

Test #20:

score: 0
Accepted
time: 167ms
memory: 16284kb

input:

100 4 3693

output:

1339808706.70986888394691050053

result:

ok found '1339808706.7098689', expected '1339808706.7098689', error '0.0000000'

Test #21:

score: 0
Accepted
time: 269ms
memory: 16276kb

input:

100 5 2252

output:

1394874243.50570420734584331512

result:

ok found '1394874243.5057042', expected '1394874243.5057042', error '0.0000000'

Test #22:

score: 0
Accepted
time: 149ms
memory: 18472kb

input:

100 50 4254

output:

1322809748.40528354560956358910

result:

ok found '1322809748.4052835', expected '1322809748.4052832', error '0.0000000'

Test #23:

score: 0
Accepted
time: 163ms
memory: 18144kb

input:

100 6 53

output:

1364441356.17009879788383841515

result:

ok found '1364441356.1700988', expected '1364441356.1700988', error '0.0000000'

Test #24:

score: 0
Accepted
time: 111ms
memory: 20308kb

input:

100 64 4337

output:

1180754550.24228390725329518318

result:

ok found '1180754550.2422838', expected '1180754550.2422838', error '0.0000000'

Test #25:

score: 0
Accepted
time: 186ms
memory: 16272kb

input:

100 7 5366

output:

1423557626.35867970669642090797

result:

ok found '1423557626.3586798', expected '1423557626.3586798', error '0.0000000'

Test #26:

score: 0
Accepted
time: 110ms
memory: 20288kb

input:

100 8 8509

output:

1353289305.35199556779116392136

result:

ok found '1353289305.3519955', expected '1353289305.3519957', error '0.0000000'

Test #27:

score: 0
Accepted
time: 308ms
memory: 18132kb

input:

100 9 1423

output:

1228887266.56616696575656533241

result:

ok found '1228887266.5661669', expected '1228887266.5661671', error '0.0000000'

Test #28:

score: 0
Accepted
time: 216ms
memory: 20220kb

input:

100 91 4806

output:

656574218.50867548829410225153

result:

ok found '656574218.5086755', expected '656574218.5086756', error '0.0000000'

Test #29:

score: 0
Accepted
time: 156ms
memory: 20280kb

input:

100 92 4024

output:

794693428.61622404074296355247

result:

ok found '794693428.6162241', expected '794693428.6162238', error '0.0000000'

Test #30:

score: 0
Accepted
time: 193ms
memory: 20216kb

input:

100 93 606

output:

677641787.48631217528600245714

result:

ok found '677641787.4863122', expected '677641787.4863122', error '0.0000000'

Test #31:

score: 0
Accepted
time: 146ms
memory: 16284kb

input:

100 94 7265

output:

686423239.26260278763948008418

result:

ok found '686423239.2626028', expected '686423239.2626028', error '0.0000000'

Test #32:

score: 0
Accepted
time: 173ms
memory: 20180kb

input:

100 95 8469

output:

328187125.92359507546643726528

result:

ok found '328187125.9235951', expected '328187125.9235951', error '0.0000000'

Test #33:

score: 0
Accepted
time: 294ms
memory: 18456kb

input:

100 96 1079

output:

492964787.62590854434529319406

result:

ok found '492964787.6259086', expected '492964787.6259086', error '0.0000000'

Test #34:

score: 0
Accepted
time: 177ms
memory: 16184kb

input:

100 97 5453

output:

258652807.79065647353127133101

result:

ok found '258652807.7906565', expected '258652807.7906564', error '0.0000000'

Test #35:

score: 0
Accepted
time: 123ms
memory: 16216kb

input:

100 98 1778

output:

159490192.11889069518656469882

result:

ok found '159490192.1188907', expected '159490192.1188908', error '0.0000000'

Test #36:

score: 0
Accepted
time: 164ms
memory: 14308kb

input:

100 99 1825

output:

33793756.32899804583576042205

result:

ok found '33793756.3289980', expected '33793756.3289980', error '0.0000000'

Test #37:

score: -100
Time Limit Exceeded

input:

1000 1 2453

output:


result: