QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#530868#7122. Overtakinggreen_gold_dog#9 1ms4268kbC++203.4kb2024-08-24 17:30:002024-08-24 17:30:06

Judging History

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

  • [2024-08-24 17:30:06]
  • 评测
  • 测评结果:9
  • 用时:1ms
  • 内存:4268kb
  • [2024-08-24 17:30:00]
  • 提交

answer

#include "overtaking.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 3'000'000'000'000'000'000;

vector<vector<pair<ll, ll>>> all;
vector<vector<ll>> ph;
vector<vector<ll>> aws;
vector<ll> ns, nw;
ll nx;

random_device rd;
mt19937 rnd(rd());

void init(int gl, int gn, vector<ll> t, vector<int> gw, int gx, int gm, vector<int> gs) {
	ll n = gn, l = gl, x = gx, m = gm;
	vector<ll> w(n), s(m);
	for (ll i = 0; i < n; i++) {
		w[i] = gw[i];
	}
	for (ll i = 0; i < m; i++) {
		s[i] = gs[i];
	}
	nx = x;
	ns = s;
	nw = w;
	vector<tuple<ll, ll, ll>> need;
	for (ll i = 0; i < n; i++) {
		if (w[i] > x) {
			need.emplace_back(t[i], w[i], i);
		}
	}
	sort(need.begin(), need.end());
	all.resize(m);
	for (auto[nt, _, ni] : need) {
		all[0].emplace_back(nt, ni);
	}
	ph.resize(m);
	for (ll i = 1; i < m; i++) {
		ll now = s[i] - s[i - 1];
		vector<tuple<ll, ll, ll>> nneed;
		ll lst = 0;
		for (ll j = 0; j < all[i - 1].size(); j++) {
			auto[nt, ni] = all[i - 1][j];
			nt += w[ni] * now;
			nt = max(nt, lst);
			nneed.emplace_back(nt, w[ni], ni);
			lst = nt;
		}
		sort(nneed.begin(), nneed.end());
		for (auto[nt, _, ni] : nneed) {
			all[i].emplace_back(nt, ni);
		}
	}
	vector<ll> to(n);
	for (ll i = 0; i < n; i++) {
		to[i] = rnd();
	}
	for (ll i = 0; i < m; i++) {
		ph[i].push_back(0);
		for (auto[_, ni] : all[i]) {
			ph[i].push_back(ph[i].back() + to[ni]);
		}
	}
	aws.resize(m);
	for (ll i = m - 1; i >= 0; i--) {
		for (ll j = 0; j < all[i].size(); j++) {
			auto[nt, ni] = all[i][j];
			ll l = i, r = m;
			while (r - l > 1) {
				ll mid = (l + r) / 2;
				if (ph[mid][j] != ph[i][j] || (j > 0 && all[mid][j - 1].first >= nt + x * (s[mid] - s[i]))) {
					r = mid;
				} else {
					l = mid;
				}
			}
			l++;
			if (l == m) {
				aws[i].push_back(nt + x * (s.back() - s[i]));
			} else {
				nt = all[l - 1][j - 1].first + w[all[l - 1][j - 1].second] * (s[l] - s[l - 1]);
				ll it = lower_bound(all[l].begin(), all[l].end(), make_pair(nt, -1ll)) - all[l].begin();
				aws[i].push_back(aws[l][it]);
			}
		}
	}
}

ll arrival_time(ll y) {
	ll nt = y;
	ll i = 0;
	ll m = all.size();
	ll j = lower_bound(all[0].begin(), all[0].end(), make_pair(y, -1ll)) - all[0].begin();
	ll l = 0, r = m;
	while (r - l > 1) {
		ll mid = (l + r) / 2;
		if (ph[mid][j] != ph[i][j] || (j > 0 && all[mid][j - 1].first >= nt + nx * (ns[mid] - ns[i]))) {
			r = mid;
		} else {
			l = mid;
		}
	}
	l++;
	if (l == m) {
		return nt + nx * (ns.back() - ns[i]);
	} else {
		nt = all[l - 1][j - 1].first + nw[all[l - 1][j - 1].second] * (ns[l] - ns[l - 1]);
		ll it = lower_bound(all[l].begin(), all[l].end(), make_pair(nt, -1ll)) - all[l].begin();
		return aws[l][it];
	}
}

#ifdef LOCAL
int main()
{
    int L, N, X, M, Q;
    assert(5 == scanf("%d %d %d %d %d", &L, &N, &X, &M, &Q));
    std::vector<long long> T(N);
    for (int i = 0; i < N; i++)
        assert(1 == scanf("%lld", &T[i]));
    std::vector<int> W(N);
    for (int i = 0; i < N; i++)
        assert(1 == scanf("%d", &W[i]));
    std::vector<int> S(M);
    for (int i = 0; i < M; i++)
        assert(1 == scanf("%d", &S[i]));
    std::vector<long long> Y(Q);
    for (int i = 0; i < Q; i++)
        assert(1 == scanf("%lld", &Y[i]));

    fclose(stdin);

    init(L, N, T, W, X, M, S);
    std::vector<long long> res(Q);
    for (int i = 0; i < Q; i++)
        res[i] = arrival_time(Y[i]);

    for (int i = 0; i < Q; i++)
        printf("%lld\n", res[i]);
    fclose(stdout);
    return 0;
}
#endif

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 9
Accepted

Test #1:

score: 9
Accepted
time: 1ms
memory: 3820kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
2500 1 78 100 1000
100000
80
0 38 51 89 92 105 117 119 122 126 142 179 259 355 385 410 419 443 483 496 551 671 691 698 709 762 778 818 860 888 897 909 930 938 946 951 955 995 1045 1091 1164 1187 1215 1243 1264 1301 1363 1409 1416 1448 1504 1518 1535 1555 1562 1597 16...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
299664
298224
299166
298008
295102
298070
297182
298650
298312
296396
296524
298070
295838
296910
296892
297374
298684
295184
295710
299062
296382
298684
298110
298008
299530
298766
295966
299062
296794
298998
299738
296418
298588
296876
295102
299860
295710
29577...

result:

ok 

Test #2:

score: 9
Accepted
time: 1ms
memory: 4000kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
80000001 1 151251000 400 1000
10000
151251252
0 563193 647572 715146 1130358 1138744 1557704 2110181 2300143 2420378 2557533 2614949 2657752 2838017 2861875 3146425 3202178 3240281 3248583 3280296 3310987 3401711 3683587 3943976 4135364 4214616 4277932 4503844 476465...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
12100095744014512
12100080944160100
12100085508223828
12100095197505388
12100090627084960
12100097311519276
12100080683026612
12100093846636708
12100099968098740
12100096796223124
12100096142019784
12100097662974856
12100083572845936
12100099936140100
121000877792...

result:

ok 

Test #3:

score: 9
Accepted
time: 1ms
memory: 3988kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
700000000 1 199 800 1000
2000
200
0 2547880 2899696 3746196 5005561 5262711 7391315 7766094 8058134 12302379 14113798 14139018 16263685 19246991 20293858 21308475 21531629 21609437 22819772 23818245 23866117 24082599 24830023 25092620 25219376 27345462 27398799 28906...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
139981678448
139714673517
139493728857
139777641660
139908912147
139434676500
139585452046
139704974839
139718370512
139701821327
139448528458
139463864882
139927337590
139754511858
139416197864
139844650005
139808181948
139577750390
139643626646
139688190761
1396...

result:

ok 

Test #4:

score: 9
Accepted
time: 0ms
memory: 4028kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
1000000000 1 99 1000 1000
1000000000000
100
0 1817308 2789727 3514387 5238876 5972281 7743105 8541339 9248161 10089380 11281389 11329343 14077050 14155477 16510318 19268709 19528706 19612683 19893513 20400622 21278533 21582205 24880066 27530395 27569486 28339765 2922...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
1099248330619
1099325193168
1099666752580
1099563034876
1099525957106
1099785654428
1099996241055
1099847005338
1099823366993
1099082743936
1099501468836
1099332698857
1099168227471
1099262165670
1099409777071
1099821586703
1099761464774
1099878195061
109999213744...

result:

ok 

Test #5:

score: 9
Accepted
time: 0ms
memory: 4032kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
1000000000 1 880000000 1000 1000
100000000000000000
880001000
0 709332 1017351 1905741 3045292 3464378 3632596 5704941 6735246 9747846 10704021 12434640 13264129 14081255 14176931 15634238 17365369 18691988 19399867 20069605 21121920 23160840 23345820 24551706 255281...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
980000473593602000
980000328241893000
980000496751131000
980000100732727000
980000460850951000
980000615531582000
980000605439144000
980000435818946000
980000696831126000
980000166079150000
980000940725540000
980000805086273000
980000698057886000
98000016833636000...

result:

ok 

Test #6:

score: 9
Accepted
time: 1ms
memory: 4040kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 498 1000 1000
100000000000000000
500
0 160783 205816 346327 347823 367191 395170 441295 639474 718881 831118 875863 1298479 1319125 1431282 1514976 1596686 1644592 1644648 1671765 1680769 1760215 1869745 1989596 2020399 2106354 2289587 2488522 2594930 272...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000049926232916
100000049864514052
100000049973025928
100000049995005458
100000049930515196
100000049843074864
100000049920623428
100000049897187068
100000049802862564
100000049946008956
100000049946867894
100000049917050904
100000049822989734
10000004993122233...

result:

ok 

Test #7:

score: 9
Accepted
time: 1ms
memory: 4268kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 401 1000 1000
100000000000000000
400
0 31311 143468 183347 233725 256130 444842 481905 486233 527809 549435 664450 1549723 1573249 1619077 1673590 1911655 1913292 2059722 2158189 2259116 2349409 2426923 2437811 2474156 2510525 2528753 2614955 2695324 2871...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000040105826882
100000040124582713
100000040181245022
100000040169641106
100000040135428053
100000040137403238
100000040172575752
100000040194573555
100000040163594943
100000040110810308
100000040187649357
100000040116517222
100000040114627594
10000004013557963...

result:

ok 

Test #8:

score: 9
Accepted
time: 0ms
memory: 3920kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
10 1 5 5 10
0
6
0 2 8 9 10
9
2
4
5
0
1
2
3
10
20

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
59
52
58
58
50
52
52
58
60
70

result:

ok 

Test #9:

score: 9
Accepted
time: 0ms
memory: 3824kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
1000000000 1 880000000 100 100
100000000000000000
880001000
0 18125472 18662947 20132713 38844162 50912725 59000193 70694095 79014902 84781895 107240650 124792182 125767204 150665436 158106715 162875579 169664865 184892442 192426843 210142654 221584689 224390935 2398...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
980000939022239000
980000210142654000
980000989457694000
980000307752813000
970286252078123694
980000000000000000
980000902460888000
980000434973267000
980000906339786000
980000526408935000
980000282731536000
980000434973267000
980000210142654000
98000016966486500...

result:

ok 

Test #10:

score: 9
Accepted
time: 0ms
memory: 3848kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 498 100 100
100000000000000000
500
0 829700 1359408 1753928 1877428 2734456 2977184 3054027 3673453 4432770 5771214 5906467 8822394 10489610 11221287 11534731 16500729 19052276 19320520 20664138 20737902 22046077 23121119 29574967 29854061 30109803 304197...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000049863849700
100000049962684802
100000049805468912
100000049838104552
100000049869485964
100000049879617250
100000049817644788
100000049913581290
100000049862347240
100000049869319444
100000049995389460
100000049802718816
100000049928978048
10000004992176166...

result:

ok 

Test #11:

score: 9
Accepted
time: 0ms
memory: 3852kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
100000000 1 401 100 100
100000000000000000
400
0 1310416 2393682 2579012 3615394 6750570 6794866 6934895 7799665 8347376 8621879 9284983 10987581 12631682 14785700 15715498 16575943 17379309 18460496 18774602 19006189 20255533 22914625 23446266 25870132 26382507 2818...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
100000040195912004
100000040167926330
100000040172845150
100000040194544782
100000040108588211
100000040142271715
100000040141179703
100000040108392021
100000040123135941
100000040177546716
100000040116164403
100000040118375302
100000040115008407
10000004017282049...

result:

ok 

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 1ms
memory: 3880kb

input:

XwWPuInrOjpekAwGKojzwKw3yVDtdkGS
2000000 100 100 2 1000
566035866 424023571 564031634 266012245 266012901 566037245 106005324 106003684 266012594 424028440 424019007 106005224 564034079 424024371 424024546 566039191 424016814 424029581 82000890 754044052 566036512 424018510 424017279 424019925 42401...

output:

mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz
OK
768035150
768029581
1144044184
308008207
768029581
768029581
956039191
768029581
956041170
768029581
768029581
308008207
956039191
308008207
768029581
768029891
1144044184
418008550
768029581
468009953
308008207
1144044184
768035150
768029581
468010817
768029581
6...

result:

wrong answer 38th lines differ - on the 1st token, expected: '308002692', found: '308000271'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%